G'day all.
Quoting PR Stanley <[EMAIL PROTECTED]>:
\_ n -> 1 + n
\_ -> (\n -> 1 + n)
The outcome seems to be identical. is there a substantive difference
between the two definitions?
Certainly, GHC compiles these to the same code. But be careful! Consider
the following two defintions:
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.
Cheers,
Andrew Bromage
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe