[Haskell-cafe] Small strings

Alexander Dunlap alexander.dunlap at gmail.com
Mon Dec 6 07:09:47 CET 2010

On Sun, Dec 5, 2010 at 10:04 PM, Antoine Latter <aslatter at gmail.com> wrote:
> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

This looks really cool! Suggestion - would it be more efficient to
provide direct text <-> smallstring or bytestring <-> smallstring
functions rather than forcing clients to go through String? That might
be useful e.g. if you were parsing (bytestring/text) data and building
a Map in the process.


More information about the Haskell-Cafe mailing list