2 ms·
It doesn't necessarily convert. You can compose with a function and the types will line up the way you'd expect, but you can't assume that the function is alway
by lmm 7y ago
It doesn't necessarily convert. You can compose with a function and the types will line up the way you'd expect, but you can't assume that the function is always being fed a single value - the function might be called zero, one, or many times, or stored to be called later. It might even dynamically be called either now or later. I find the most common misconception is to assume that all monads are "container-like", somehow having a value "inside" them. Whereas actually it's much more general than that.
I'd recommend playing around with some non-container monads - e.g. future or continuation. Personally I found it was easier to grasp the general case once I had experience with a bunch of specific examples.
- dmix 7y agoIt’s also helpful to eventually learn Haskell and learn why they needed something like Monads to cleanly solve various problems given the safety and purity constraints imposed by the language. http://cs.coloradocollege.edu/~bylvisaker/MonadMotivation/ http://cs.coloradocollege.edu/~bylvisaker/MonadMotivation/ Although that can quickly turn into an academic rabbit hole of theory so it helps to keep it connected to your real world usage instead of getting fancy. Which is why I found it helpful to learn in the context of actually using Haskell and playing with real code.