[Haskell-cafe] Using Product Algebraic types

Sven Panne Sven.Panne at aedion.de
Mon Jul 5 13:11:56 EDT 2004

David Menendez wrote:
> Neat! Are you getting this from -ddump-simpl?

Yep, that's the most readable intermediate form to look at IMHO.

> [...]
>     helper2 = \ds eta ->
>         case ds of
>           (n,a) -> ( case eta of
>                        (x,y) -> x `plusInt` y
>                    , case eta of
>                        (x,y) -> y
>                    )
> [...] I don't know what to make of that. Semantically, helper2 is identical to
> helper, but I'm not brave enough to look at the C output to see if they
> produce different results.

Well, they are almost equivalent: If you keep the second element of the result of
helper2 alive without having it evaluated, you keep the first element of the
second argument of helper2 alive, too. Depending on the usage of helper2, this
might make a difference in the space behaviour, but in our current example it
doesn't matter very much. If in doubt, use e.g. GHC's profiling facility, which
can produce nice & colourful graphs, useful for impressing your friends... :-)


More information about the Haskell-Cafe mailing list