Understanding strictness of ghc output

Simon Marlow simonmar at microsoft.com
Tue Jun 22 08:39:57 EDT 2004

On 22 June 2004 13:30, Adrian Hey wrote:

> I'm trying to figure out how you tell if ghc has correctly infered
> strictness or whether or not a little more prompting from me
> is needed.
> I tried compiling with -ddump-simpl, and I guess from looking
> at this the DmdType bit is what I want (maybe). So if I have
> "DmdType LS" for a function of arity 2, does this mean the
> function is lazy in the first argument and strict in the second?
> I would be pretty confident that this was the correct interpretation,
> but this is the Haskell code (from AVL library)..
> height :: AVL e -> Int
> height = addHeight 0 where
>  addHeight h  E        = h
>  addHeight h (N l _ _) = addHeight h+2 l
>  addHeight h (Z l _ _) = addHeight h+1 l
>  addHeight h (P _ _ r) = addHeight h+2 r
> It seems pretty obvious to me that addHeight is strict in its
> first argument if + is strict for Ints (as I guess it is). But this
> gives "DmdType LS".

Could you post the actual Core?  I agree that addHeight looks strict in
its first argument.


More information about the Glasgow-haskell-users mailing list