Proposal: Add concatMapM function (#2042)

Ketil Malde ketil+haskell at
Fri Feb 1 02:52:02 EST 2008

Bulat Ziganshin <bulat.ziganshin at> writes:

Bulat Ziganshin <bulat.ziganshin at> writes:

> the right way to deal with [text encoding] "modifiers" is to attach
> them to the Handle itself like this:
> f <- openFile "name" >>= withLocking >>= withEncoding utf8

This is nice!

I think the Haskell Way of interpreting bytes as Latin-1 - while
unfortunate in today's multi-everything environment - is something we
just have to live with.  Too much code expects this behavior, and too
many tasks require just reading ASCII to be burdened with
complications of locales and character sets.

Attaching modifiers to handles appears to solve the problem of
retaining 100% backwards compatibility, while opening for dealing with
modern character sets.

Somebody raised the question of reading a Content-type field, etc:
would it be possible to "rewind" a handle after setting encoding?  For
Content-type fields, I suspect the header is usually limited to ASCII
anyway, so adding decoding for subsequent text is probably
sufficient.  But how about a 'withDefaultEncoding' modifier that
inspects the first two (or four?) bytes for a Unicode BOM, and either
sets decoding accordingly and continues, or sets encoding according
to locale *and* lets the user read the first bytes when reading from
the handle.

If I haven't seen further, it is by standing in the footprints of giants

More information about the Libraries mailing list