Optimisation of unpackCString#

Neil Mitchell ndmitchell at gmail.com
Tue Apr 29 13:39:28 EDT 2008


>  > Cons: Makes the simplifier slightly more complex - but I hope not by much!
> And it doesn't work for my case -- I'd really want length as a compile
>  time constant.
>  Could you elaborate on what kind of rules you think we could write with
>  the ability to get the head?

One of my ideas was some RULES that expand:

test x | "neil" `isPrefixOf` x = ...
          | "ned" `isPrefixOf` x = ...

And obtains direct pattern-matching code. I have a lazy
continuation-based parsing library which could use this extensively.
See my other ongoing thread on this mailing list for more details of
where this is going.

>  The rule I'd like to write is:
>     "pack/packAddress" pack (unpackCString addr) = ByteString (length# xs) 0 addr

That requires Proposal 2, so needs to have an API defined -- including
length# and some others. Out of curiosity, how much performance boost
would this give in ByteString?

> That sounds great!  Please let's have a chat before you sail in -- I have a good idea where to put this.

Simon: I will email you in a couple of weeks to discuss it.



More information about the Glasgow-haskell-users mailing list