[Haskell-cafe] Precedence (Part 2)
prstanley at ntlworld.com
Thu Apr 3 13:42:09 EDT 2008
> let f = sum.map (^2).filter even
> f [1..4]
So far so good!
> sum.map (^2).filter even [1..4]
returns an error.
How is it that the composition above as part of a function equation
doesn't return any errors while on its own it requires parentheses?
You seem to have expression evaluation confused with cpp/m4 macros.
The `f' in `f [1..4]' is not expanded as text to `sum.map (^2).filter
even [1..4]'; it is evaluated as a function whose definition will
(when needed! lazy language) eventually turn out to be `sum.map
If you really must view it as a text macro substitution, then imagine
that every macro expansion has a set of parentheses added around it.
Okay, so it's not expanded like a CPP macro. How is it evaluated?
What happens to the sum.map ... definition if it's not simply used to
More information about the Haskell-Cafe