[Haskell-cafe] Origins of '$'
lrpalmer at gmail.com
Sun Dec 7 05:34:54 EST 2008
On Sun, Dec 7, 2008 at 3:05 AM, Hans Aberg <haberg at math.su.se> wrote:
> One can define operators
> a ^ b := b(a) -- Application in inverse.
> (a * b)(x) := b(a(x)) -- Function composition in inverse.
> (a + b)(x) := a(x) * b(x)
> O(x) := I -- Constant function returning identity.
> I(x) := x -- Identity.
> and use them to define lambda calculus (suffices with the first four;
> Church reverses the order of "*").
The simple elegance of writing this encoding just increased my already
infinite love of Haskell by another cardinality.
a .^ b = b a
(a .* b) x = b (a x)
(a .+ b) x = a x .* b x
o x = i
i x = x
toNat x = x (+1) 0
fromNat n = foldr (.) id . replicate n
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe