Fwd: [Haskell-cafe] Optimising UTF8-CString -> String marshaling,
plus comments on withCStringLen/peekCStringLen
Alistair Bayley
alistair at abayley.org
Mon Jun 4 11:14:30 EDT 2007
(this time include the list, too)
---------- Forwarded message ----------
From: Alistair Bayley <alistair at abayley.org>
Date: 04-Jun-2007 16:13
Subject: Re: [Haskell-cafe] Optimising UTF8-CString -> String
marshaling, plus comments on withCStringLen/peekCStringLen
To: Duncan Coutts <duncan.coutts at worc.ox.ac.uk>
On 04/06/07, Duncan Coutts <duncan.coutts at worc.ox.ac.uk> wrote:
>
> Are you sure fromUTF8Ptr is strict in its ptr arg? Try with a ! pattern
> on that arg. You'll need -fbang-patterns.
Is there some semantic advantage to bang-patterns, or is it just a
syntactic convenience? 'cause once the guard is in there, it's not
much bother to maintain.
> You can also get ghc to tell you what strictness it inferred for your
> functions. It's shown in the .hi file. Use ghc --show-iface UTF8.hi.
I tried -ddump-hi and got:
$wfromUTF8Ptr :: base:GHC.Prim.Int#
-> base:GHC.Ptr.Ptr base:GHC.Word.Word8
-> base:GHC.Base.String
-> base:GHC.Prim.State# base:GHC.Prim.RealWorld
-> (# base:GHC.Prim.State# base:GHC.Prim.RealWorld,
base:GHC.Base.String #)
{- Arity: 4 Strictness: LSSL -}
Assuming the LSSL tokens are in the same order as the function
arguments, the first argument is lazy - GHC.Prim.Int#. hmmm.... some
cognitive dissonance here.
I'm a bit puzzled as to why it's in the .hi file at all - it's not an
exported function.
(I also see quite a bit of code in the hi-dump. Presumably this
permits cross-module inlining, for those selected functions?)
Alistair
More information about the Haskell-Cafe
mailing list