Optimisation of unpackCString#
Don Stewart
dons at galois.com
Mon Apr 28 17:04:14 EDT 2008
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
More information about the Glasgow-haskell-users
mailing list