[Haskell-beginners] Basic "data" question

Ozgur Akgun ozgurakgun at gmail.com
Thu Nov 24 13:26:23 CET 2011


Hi Roger,

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
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111124/8f9357bf/attachment.htm>


More information about the Beginners mailing list