3 ms·
Not just terminology. It's more like there's only two levels of Haskell: first it's understandable and I say, "Okay just step by step and I got this. Then all o
by commentzorro 11y ago
Not just terminology. It's more like there's only two levels of Haskell: first it's understandable and I say, "Okay just step by step and I got this. Then all of a sudden we run smack into something like this big wall of WFT:
* The infix application function (ma>>=\a->f(a)), commonly called bind, executes the computation ma to expose its effects, calling the resulting value a, and passes that to function f. Evidently, the result of this application (f a) should again be a potentially side-effecting computation; hence, the type signature for bind looks like this:
(>>=):: M a -> (a -> M b) -> M b.
* The injection function (return a) injects a pure value into a computation. Its type signature is: return :: a -> M a.
In practice, each effect usually comes with so-called nonproper morphisms. These domain-specific operations are unique to that effect ...
Seriously, how can I hack around and understand this?
- marcosdumay 11y agoOh, God, you just came to the Monad definition... From my experience, it only really falls in place after you write your first or second monad. To learn that you go in that order: 1 - Get used to use the IO monad in do notation. 2 - Learn a couple more monads. I'd recommend State and one of Parsec or Attoparsec. (As a bonus, use a bit of applicative syntax too.) 3 - Get used to write some somewhat complex one liners without the do notation. 4 - Abuse the List monad for practice. 5 - Write your own. All the time, look at the types as much as you need, but do not obsess over them.