
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

On Mon, Dec 6, 2010 at 8:04 AM, Antoine Latter
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.
Is there a reason that you don't include an IsString instance? Michael

On Sun, Dec 5, 2010 at 10:04 PM, Antoine Latter
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@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. Alex

On Mon, Dec 6, 2010 at 12:09 AM, Alexander Dunlap
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.
I'll try to come up with a direct writer from text/bytestring and see
how they stack up against going via list. I expect the direct approach
to be faster if only because asking text/bytestring for their length
will be cheaper than asking a String for its length.
I'm a bit skeptical about the to/from bytestring function, though, as
I then provide a convenient way to get to String without specifying an
encoding. But I suppose folks will want it.
On Mon, Dec 6, 2010 at 12:08 AM, Michael Snoyman
Is there a reason that you don't include an IsString instance?
Michael
Laziness! This one should be easy. Antoine
participants (3)
-
Alexander Dunlap
-
Antoine Latter
-
Michael Snoyman