4 ms·
Ok well, in my free time, I was reading learnyouahaskell.com (Which, by the way, is pretty great but a bit slow-ish if you aren't new in the functional way of t
by d0m 17y ago
Ok well, in my free time, I was reading learnyouahaskell.com (Which, by the way, is pretty great but a bit slow-ish if you aren't new in the functional way of thinking).
And I was kind of anticipating monads since I keep hearing that they just blow your mind and are hard to understand. So, I was happy to read this article and found it quite good actually :) Good job to the author.
Here's how I can summarize it: monads are a kind of pattern which "implements" ">>=" and "return" as a Int implements "eq" or "ord". The job of >>= is to act a little bit like the Null Pointer pattern in the OO world. For instance, if everything is ok, it returns the good value else it throws an exception or return an error value. However, to use the >>= function, you need to encapsulate your first value. Depending of monads, that "encapsulated" value may be different. In this article, we were working with the Maybe type, however, monads can be of any type. So, the "return" function takes care of encapsulating the value in the right type so that the >>= function can use it.
Anyhow, that's what I understood ;-) And I'll continue to read learnyouhaskell.com
- deleted 17y ago[deleted]