Optimisation of unpackCString#
Neil Mitchell
ndmitchell at gmail.com
Mon Apr 28 17:02:45 EDT 2008
Hi
> The first case makes sense, and is just a RULE. Though it seems GHC already
> does this?
>
> g = head ""
>
> goes to:
>
> M.g = badHead @ Char
>
> without prompting.
Nope, as far as I can tell "" gets translated to [], not
unpackCString# "" - hence the unpack never gets in the way. If you had
the second rule, you'd soon want the first.
> So I wondered if I could write a rule for head/unpackCString
>
> Urgh. not what we want though. GHC won't index the string at compile time,
> and I can't write a RULE for it.
Yeah, I tried that too...
> Perhaps you can newtype Char and use string overloading to work around the
> packing issue?
That would work on GHC, but not on Hugs.
Thanks
Neil
More information about the Glasgow-haskell-users
mailing list