42 ms·
It's not a bad example but lacking generality and more importantly explicit types. It's really all about connecting types like LEGO blocks, so the important th
by jstimpfle 10y ago
It's not a bad example but lacking generality and more importantly explicit types.
It's really all about connecting types like LEGO blocks, so the important thing is to show the type signatures.
"bind" is the function required from Haskell's Monad typeclass, but not a good choice to explain monads. It's much cleaner to explain monads as functors with "join" and ("inject" aka return).
map :: (a -> b) -> (M a -> M b)
join :: M (M a) -> M a
inject :: a -> M a
With these guys you can easily compose "dirty" asymmetric operations like (readFile :: FilePath -> IO Bytes)