
1 Sep
2013
1 Sep
'13
9:16 a.m.
On Sun, 1 Sep 2013, Artyom Kazak wrote:
On Sun, 01 Sep 2013 15:18:32 +0400, Erik de Castro Lopo
wrote: Err, mapM is defined as:
mapM :: Monad m => (a -> m b) -> [a] -> m [b]
Yeah, the signatures for mapM_ and mapM would respectively be
mapM_ :: Monad m => (Word8 -> m b) -> ByteString -> m ()
This one should not be a big problem, but could be done by calling mapM_ on the result of ByteString.unpack.
mapM :: Monad m => (Word8 -> m Word8) -> ByteString -> m ByteString
This one can become very inefficient. Think of m = [], then many ByteStrings have to be constructed by repreated ByteString.cons which requires a lot of copying. For lists "cons" aka (:) is efficient because the tails are shared.