Re: [Haskell] Re: ANNOUNCE: FPS - FastPackedStrings 0.2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell] Re: ANNOUNCE: FPS - FastPackedStrings 0.2

Donald Bruce Stewart
Moved to libraries@

tomasz.zielonka:
>
> And a String class would allow typing FastPackedString literals directly.

On this last matter, you can almost do it:

    FPS.packAddress "haskell"#
or
    FPS.unsafePackAddress 7 "haskell"#

The latter is an O(1) op, the former performs a strlen on construction.
And with the magic RULE, you get:

    {-# RULES
    "pack/packAddress" forall s# .
                       pack (unpackCString# s#) = packAddress s#
     #-}

such that:
    FPS.pack "haskell"

usually gives you the right thing. Ideally I'd like a way to get the strlen
from the compiler, to make O(1) packAddress using

-- Don
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell] Re: ANNOUNCE: FPS - FastPackedStrings 0.2

Tomasz Zielonka
On Thu, Apr 20, 2006 at 07:24:18PM +1000, Donald Bruce Stewart wrote:

> And with the magic RULE, you get:
>
>     {-# RULES
>     "pack/packAddress" forall s# .
>                        pack (unpackCString# s#) = packAddress s#
>      #-}
>
> such that:
>     FPS.pack "haskell"
>
> usually gives you the right thing.

Cool! :-)

Best regards
Tomasz
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries