4 ms·
You're probably over-thinking this. Monad is not a difficult concept, but it is very abstract. Because of that, it's hard to say specifically that "this" is wha
by jinfiesto 10y ago
You're probably over-thinking this. Monad is not a difficult concept, but it is very abstract. Because of that, it's hard to say specifically that "this" is what Monad "does."
Also, monad and monoid are orthogonal ideas in Haskell. Monad doesn't follow from monoid.
Personally, I would just think of Monad as "thing with bind & return." Basically all of the magic of any Monad happens in its bind function. What makes Monad interesting (imo) is that for any type that can be a Monad there are typically only one or two possible implementations of bind that fulfill the Monad laws.
I guess my advice would be to put getting an intuition for Monad on hold. The reason being that most Monads behave very differently from each other (this is a testament to the power of the concept, that it can tie together so many seemingly unrelated ideas.) Just read a bunch of Monad implementations and verify that they fulfill the laws (make sure to also have the typeclass definition in the back of your head.)
To get you started, I recommend you wrap your head around the Maybe, Either e, State, Reader and Writer monads in that order. Unfortunately, you won't be able to look at Haskell source to read these Monads, as their implementations now all use Monad Transformers if I'm not mistaken. You should still be able to find straightforward implementations of these Monads floating around in internet tutorials.
Also, if you intend to have a serious go at Haskell, I recommend the NICTA course as a no-bullshit approach. (Warning: not for the faint of heart. Especially if you're going it alone.)
https://github.com/tonymorris/course https://github.com/tonymorris/course