[Haskell-cafe] Small strings

Antoine Latter aslatter at gmail.com
Mon Dec 6 07:04:18 CET 2010


Hi Haskell,

I've recently created the 'smallstring' package[1] and put it on
Hackage. The goal was to create a string-like type with as little
memory overhead as possible, and to have equality and comparison
operations be competitive with the native String type. The idea is
that this type would make ideal keys into data structures like
Data.Map.

I've taken pains to make the library portable to other compilers, but
this isn't really tested, and most of my recent development has been
on GHC 7. The library is young and likely has places it could be
improved, so your feedback is welcome.

The API provided is small - to/fromString along with Eq and Ord instances.

This isn't meant to be a replacement for the text[2] or bytestring[3]
packages - the reduced size comes at a cost. Both of these libraries
offer substring manipulation functions which allow the sharing of the
backing memory buffers. Also, I haven't implemented any sort of
string-like operations on the type as it isn't the right thing for
that.

I've borrowed heavily from the previously mentioned text package for
the underlying array implementation, so thanks goes to Bryan
O'Sullivan for maintaining the package and to all of the other authors
as well.

Take care,
Antoine

[1] http://hackage.haskell.org/package/smallstring
[2] http://hackage.haskell.org/package/text
[3] http://hackage.haskell.org/package/bytestring



More information about the Haskell-Cafe mailing list