Hi Mark,
Suppose I have functions
f :: Int -> Int f x -> x * x
I suppose you mean: f x = x * x
g :: Int -> Int g x -> x + 1
The lazy application operator "$" allows me to do:
f $ g x
instead of
f (g x)
But I don't understand why it works this way! Let me explain.
f is a function, and application has highest precedence, so unless it sees a bracket, it should take the next thing it sees as an argument.
Yes, but "$" cannot be an argument. In the Haskell grammar for expressions ( http://www.haskell.org/onlinereport/exps.html ) an application (fexp) consists of one or aexp's and an aexp cannot be an operator (at least not, without parentheses around it). A simpler way to see this is to write application as an explicit operator. Let's call it @. Above expression then reads f $ g @ x And @ binds stronger than $, alas f $ (g @ x) Arjan