Thinking about what's missing in our library coverage

wren ng thornton wren at community.haskell.org
Tue Aug 4 20:02:25 EDT 2009


Isaac Dupree wrote:
>>>    * Data.Map String Int
>>>    * Data.Map ByteString Int
>>>    * bytestring-trie
> 
> What about a Unicode/text aware version of ByteString?  I mean, I 
> suspect people will want to use this map for strings of characters, and 
> I want to make sure we don't hardcode a type that will cause us trouble 
> in the future (and I have this idea in my head that ByteString is 
> supposed to represent byte-sequences and not character-sequences).

The bytestring-trie package uses ByteStrings as a vector of bytes. That 
is, there's no built in support for or against textual data (modulo 
byte==char traditions). Anything that can be rendered into a ByteString 
can be tried (with performance depending on the suitability of the 
encoding). I can't really see any way to make use of knowing that the 
data is textual, though.

I've thought about adding a typeclass to automate the encoding/decoding 
between various "string" types and the ByteStrings used internally. 
Unfortunately such a class would have a very large number of methods, 
and is of dubious utility in the big picture. All in all, the problem of 
rendering an abstract string into a sequence of bytes belongs to another 
package.

-- 
Live well,
~wren


More information about the Libraries mailing list