Imperative Notation

Zuurbier, E. - AMSXE Erik.Zuurbier@KLM.NL
Fri, 12 Feb 1999 11:17:13 +0100


If you manage to abstract away more than one environment/state, then the
ultimate thing
would be to abstract away *all* variables from a program. Actually, this was
achieved
in 1958 by Curry and Feys. Simon Peyton Jones describes it in his classic
"The Implementation of Functional Programming Languages" (1987).

It is done with so called SK combinators. The book gives  the greatest
common divisor function as an example:
gcd = S` S (C (B IF (= 0))) (B (S gcd) REM)

The combinators reduce as follows:
S f g x -> f x (g x)
C f g x -> f x g
S`c f g x -> c (f x) (g x)
B f g x -> f (g x)

This gcd function contains only functions, combinators and other constants,
no variables.

SK-combinators were never meant as a language for a human to write programs
in, 
but as an intermediary language for implementation. But whoever hates
explicit
environment passing could dig SK-combinators up and see if they can be
restyled to make them
human readable and writeable after all.

By the way, SK-combinators were probably forgotten before monads and
uniqueness types
were invented. So maybe they don't go together.

Regards Erik Zuurbier