test1 n _ = 1 + n
    test2 n = \_ -> 1 + n

I don't know if it's still the case, but GHC used to compile different
code for these at high optimisation levels.  The first was essentially
compiled to:

    test1 = \n _ -> 1+n

And the second to:

    test2 = \n -> let x = n+1 in \_ -> x

The difference is that test1 is faster if it's usually fully applied,
test2 is fully lazy.
Fully lazy? Can you elaborate please?
Thanks, Paul

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to