Exercise solution: map and mapM


Implement map and mapM from Pipes.Prelude. They have the following types:

map  :: Monad m => (a ->   b) -> Pipe a b m r
mapM :: Monad m => (a -> m b) -> Pipe a b m r

You can write these definitions using only the functions we have seen already: yield, await, and lift.


Sign up for access to the full page, plus the complete archive and all the latest content.