
28 Apr
2008
28 Apr
'08
9:04 p.m.
ndmitchell:
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.
Optimisation and Hugs don't go together anyway. -- Don