Dr. Benjamin Pierce's "Types and Programming Languages" mentions the identify function on page 55:
$id = \lambda x.x$;
I understand the identity function from usage in Haskell:
id' :: a -> a
id' x = x
It accepts a single argument and returns it.
But, what does $\lambda x.x$ mean in the above id function's right-hand side? Please break down each component of the function.
Example, in the Haskell id', id' is the function's name. a is the input type and a is the output type. The x represents the input argument value and, consequently, the output value.
Let's try to break down the syntax of
λx. xinto pieces:λmeans that you are dealing with an abstraction (it is a fancy word for function in programming sense). It doesn't mean anything and it is there just for parsing purposes. See here if you are curious why this particular letter was chosen.xoccurrence -- it is called binding occurrence -- is a formal parameter name, just like Haskell's version firstxafterid..is a separator between the formal parameter name and the abstraction's body. It's there for parsing only.xconstitutes the abstraction's body, which is like a Haskell function's body.A couple comments:
=. So if you see something likeid yyou need to do "macro-expansion" ofidto get a valid $\lambda$-term.λx. xis usually not a valid $\lambda$-term as well. It is syntactic sugar for(λx. x). It is customary to get rid of the top-level parentheses and to drop some more parentheses while introducing the rules that prevent ambiguity.