Re:Functional Programming Jargon
by jstimpfle on Sunday July 24, 2016 @01:45PM
(#12154007)
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)
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).
With these guys you can easily compose "dirty" asymmetric operations like (readFile :: FilePath -> IO Bytes)