July 2023
Intermediate to advanced
670 pages
17h 13m
English
For all of the virtual ink spilled in pursuit of monad tutorials, the reality is that monads aren’t actually as complicated or terrible as everyone makes them out to be. Monad is actually just a type class, with a few rules about how the functions defined in the type class should work.
| | class Applicative m => Monad m where |
| | infixl 1 >>= |
| | (>>=) :: m a -> (a -> m b) -> m b |
| | |
| | infixl 1 >> |
| | (>>) :: m a -> m b -> m b |
| | a >> b = a >>= \_ -> b |
| | |
| | return :: a -> m a |
These functions should all look pretty familiar! Nearly everything that we’ve been doing so far with IO in this chapter comes from its Monad type class instance! You’ll also recognize Applicative from the last section, so with every ...
Read now
Unlock full access