[Haskell-cafe] FastString a misnomer

John Meacham john at repetae.net
Thu Oct 20 21:43:04 EDT 2005


On Thu, Oct 20, 2005 at 10:45:28AM +0100, Simon Marlow wrote:
> I think when this is ready it should replace Data.PackedString.
> 
> I don't necessarily mean put it into fptools/libraries/base - we could
> just remove the existing Data.PackedString from there and your separate
> package can provide Data.PackedString.  That is, unless we decide to use
> it in GHC in some way, in which case we'll have to pull (a copy of) it
> into fptools/libraries.

We should make 'PackedString' the UTF8 wrapper though and provide
Data.ByteArray as a separate library. If it has string in the name, one
should be able to replace strings with it everywhere and expect the
right thing to happen as enforced by the type system. that and C's
conflation of characters and bytes and Haskell 98s lack of clearing up
the issue has been a huge pet peeve of mine.

A nice representation is actually pure UTF8 with a number of characters
Int# as well as a number of bytes Int#. it not only makes length fast
but lets you very easily test of the string is just ASCII if the two
numbers are the same and use optimized routines, much better than a
flag.

the constructors should also verify everything is properly encoded UTF8
so the conversion to string functions can be very fast without worrying
about error checking.

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈ 


More information about the Haskell-Cafe mailing list