What is the difference between combinator and supercombinator? Both of them do not contain any free variables. That is the one thing, that I know.
-
2Explanation and an example of a combinator that is not a supercombinator can be found here: wiki.haskell.org/Super_combinatorRuud Helderman– Ruud Helderman2019年02月20日 13:30:56 +00:00Commented Feb 20, 2019 at 13:30
1 Answer 1
A supercombinator is either a constant, or a combinator which contains only supercombinators as subexpressions.
Or more completely,
Any lambda expression is of the form \x1 x2 .. xn -> E, where E is not a lambda abstraction and n≥0. (Note that if the expression is not a lambda abstraction, n=0.) This is a supercombinator if and only if:
- the only free variables in E are x1..xn, and
- every lambda abstraction in E is a supercombinator.
A combinator does not contain any free variable, but might have a subexpression that does. For example, from Haskell Wiki: Super combinator
\f g -> f (\x -> g x 2)
the outer lambda function is indeed a combinator because it has no free variables, however its subexpression \x -> g x 2 has a free variable (g), so it is not a combinator. It follows that \f g -> f (\x -> g x 2) cannot be a supercombinator
2 Comments
\x -> x cannot be a super combinator, because (1) it is not a constant, and (2) it contains a subexpression x, which is not a super combinator.