
20 Sep
2007
20 Sep
'07
1:30 a.m.
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