[Haskell] Re: ANNOUNCE: FPS - FastPackedStrings 0.2

Tomasz Zielonka tomasz.zielonka at gmail.com
Thu Apr 20 05:16:29 EDT 2006


On Thu, Apr 20, 2006 at 10:32:37AM +1000, Donald Bruce Stewart wrote:
> ashley:
> > Donald Bruce Stewart wrote:
> > 
> > >    Interface:   
> > >    http://www.cse.unsw.edu.au/~dons/fps/Data.FastPackedString.html
> > 
> > Given that FastString turns out to be an array of Word8, why are you using Char at all?
> 
> Convenience. Some historical legacy from darcs. And others have
> contributed patches specifically to add more Word8 support.

I think the biggest barrier to using Word8 operations on String-like
types is the Read/Show instance for Word8, which works like for other
Word types:

  Prelude Data.Word> map (toEnum . fromEnum) "Haskell" :: [Word8]
  [72,97,115,107,101,108,108]

Maybe we should introduce a Char8 type, or something like that, which
would have the nice Stringy presentation?

There is also a problem with literals. How about solving it by adding
a Num-like Character class? Consider:

    Prelude> :t 1
    1 :: (Num t) => t
    Prelude> :t "abc"
    "abc" :: CharAscii c => [c]
    Prelude> :t "aąbcć"
    "aąbcć" :: CharUnicode c => [c]

or even:

    Prelude> :t "aąbcć"
    "aąbcć" :: CharacterPolish c => [c]

;-)

And a String class would allow typing FastPackedString literals directly.

Best regards
Tomasz


More information about the Haskell mailing list