mapM_ for bytestring

Henning Thielemann lemming at henning-thielemann.de
Sun Sep 1 20:55:10 CEST 2013


On Sun, 1 Sep 2013, Artyom Kazak wrote:

> On Sun, 01 Sep 2013 17:16:49 +0400, Henning Thielemann 
> <lemming at henning-thielemann.de> wrote:
>
>>> 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.
>
> As I’ve said, mapM_ through ByteString.unpack is four times slower than 
> the hand-written version. I find it unacceptable that a simple counting 
> sort *can’t* be written efficiently for ByteString without importing 
> Data.ByteString.Unsafe, Foreign.Ptr and friends.

A possible solution might be fusion rules for ByteString.unpack and mapM_.


More information about the Libraries mailing list