On 24 November 2011 10:43, Costello, Roger L.
<costello@mitre.org> wrote:
data Var = V | W | X | Y | Z
data Lambda = Variable Var | Application Lambda Lambda | Abstraction (Variable Var) Lambda
data Lambda = Variable Var | Application Lambda Lambda | Abstraction Lambda Lambda
You can use the above declaration to successfully create your example lambda terms. However, it doesn't stop you from constructing things like:
Abstraction (Application .. ..) (Variable ..)
If you want to go to that land, you either need smart constructors (simpler) or GADTs (more hairy, unfortunately).
HTH,
Ozgur