[Haskell-beginners] Basic "data" question
ozgurakgun at gmail.com
Thu Nov 24 13:26:23 CET 2011
On 24 November 2011 10:43, Costello, Roger L. <costello at mitre.org> wrote:
> data Var = V | W | X | Y | Z
> data Lambda = Variable Var | Application Lambda Lambda | Abstraction
> (Variable Var) Lambda
Variable is a constructor of the data type Lambda. Abstraction is another.
You use Variable as if it was a data type while defining Abstraction.
data Lambda = Variable Var | Application Lambda Lambda | Abstraction 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).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners