Meanwhile I find monads very useful in Scala, even without any laziness in sight.
Meanwhile I find monads very useful in Scala, even without any laziness in sight.
The `Maybe` (or `Option`) monad, for instance, has the single effect
fail :: Maybe a
fail = Nothing
as soon as `fail` is "evaluated". Evaluation here is in the monadic sense - and is not related to the evaluation strategy of the host language.List monads have a non-determinism operational interpretation. The `State`, `Writer` and `Continuation` monads obviously do as well.
You could say the `Reader` monad has the single effect
ask :: Reader e e
but thinking about this operationally is certainly not that helpful as this returns a single constant value from the environemnt.The same thing goes for `Free` which is essentially a data structure for the abstract syntax of Monads. However in some sense even for this part of you understanding of free monads is likely based in providing a natural transformation to an interpretation in another monad (i.e. `iterM`)
(I believe there are good reasons you would want to use monads, but only from a denotational perspective, not an operational one)
> Meanwhile I find monads very useful in Scala, even without any laziness in sight.
But do you use monads for all the things Haskell programmers use them for? Or only a subset of those things?
Almost all projects end up needing to care about performance at some point or other, if only a little. (So yes, Haskell is probably not a suitable language for most projects, sadly)
> But do you use monads for all the things Haskell programmers use them for? Or only a subset of those things?
All the things, as far as I'm aware. Certainly the obvious ones like IO.