2 ms·
Just for reference, I didn't actually write that code--whoever commented on GitHub did. There's one very important note to add: monads are much more general th
by tikhonj 14y ago
Just for reference, I didn't actually write that code--whoever commented on GitHub did.
There's one very important note to add: monads are much more general than just this particular example. A monad is any type with certain operations; it can encode different behaviors. In this case, the type (Map [Char] Integer -> a) is a monad, representing a value reading from the Map. However, you can also have other monads like Maybe a, which represents a value that may not exist.
I don't think I can really describe monads completely here, so you'll have to look up some resources elsewhere. It's just very important to realize that monads are much more general than this specific example.