Optimisation of unpackCString#
ndmitchell at gmail.com
Mon Apr 28 17:02:45 EDT 2008
> 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.
More information about the Glasgow-haskell-users