3 ms·
The operational perspective is valid but it doesn't help to answer the question, IMO. If your answer to "what is the problem?" is "the problem is our hard-to-pr
by lmm 8y ago
The operational perspective is valid but it doesn't help to answer the question, IMO. If your answer to "what is the problem?" is "the problem is our hard-to-predict evaluation strategy", then the beginner's natural follow-up question is "why not just use a normal evaluation strategy?", and there's no good answer to that one (indeed many regard Haskell's laziness as the wrong choice; in recent times we've seen post-Haskell languages e.g. Idris moving away from it, and the best-known industrial deployment of Haskell uses a strict variant).
Meanwhile I find monads very useful in Scala, even without any laziness in sight.
- AnimalMuppet 8y agoIf you actually need to care about the evaluation strategy, then Haskell may not be the language for your project. > 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?
- Retra 8y agoMost projects do not make a language choice based on the needs of the model, but based on the needs of the developers. It's the same reason you've chosen English to write your comment in, rather than some other language that might express it better.
- lmm 8y ago> If you actually need to care about the evaluation strategy, then Haskell may not be the language for your project. 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.
- alipang 8y agoMost monads I'm aware of have an operational interpretation. 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`)
- lmm 8y agoLike I said, operational interpretations are valid, but they don't help explain why monads are useful, because if you only want the operational interpretation then why not build the operational functionality directly into the host language (particularly since most host languages already offer that kind of thing)? E.g. the operational version of Maybe/Option just seems like an overcomplicated version of exceptions - if all you want is a "fail" effect, why not just have it throw an exception and avoid all the extra monadic plumbing. (I believe there are good reasons you would want to use monads, but only from a denotational perspective, not an operational one)