Reputation: 34099
I am trying to understand CAF from the page https://wiki.haskell.org/Constant_applicative_form and confuse about the difference between ((+) 4)
and \x -> (+) 4 x
?
Why is the first a CAF and the later not? As a beginner, I can not see the difference.
Upvotes: 3
Views: 84
Reputation: 2955
One way to read this is that:
((+) 4)
is an expression that produces the function: \x -> (+) 4 x
\x -> (+) 4 x
is that function already.
And functions are not CAFs (we don't apply anything there).
Upvotes: 3