3 ms·
So do you need monads in Haskell because that's the only way you could do some of the things that are trivial in an imperative language (albeit verbose and argu
by fizixer 6y ago
So do you need monads in Haskell because that's the only way you could do some of the things that are trivial in an imperative language (albeit verbose and arguably inelegant)?
- exdsq 6y agoThis is the paper that introduced them to FP, if you’re interested in the original reasoning. https://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf https://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/b...
- mrkeen 6y agoNo
- Koshkin 6y agoYes. (For example, ML, being impure, does not need this.)
- dependenttypes 6y agoHaskell only "needs" monads for IO (there are other alternatives to implement io in a pure language too though). The reason that they are popular in haskell is that they are convenient and the reason that they are not popular in ML is that it lacks higher order types and things like typeclasses.
- y2bd 6y agoNot exactly. For example, IO actually existed in Haskell before the IO Monad. It essentially used lists injected and retuned from the main function, plus the fact that Haskell is lazily evaluated (so those IO commands in the list wouldn’t be evaluated until main is run): https://stackoverflow.com/questions/17002119/haskell-pre-monadic-i-o https://stackoverflow.com/questions/17002119/haskell-pre-mon...
- dependenttypes 6y agoGo is imperative and could really use some monads, especially for error handling. It has nothing to do with a language being pure or not really.