[Haskell-beginners] Beginners Digest, Vol 41, Issue 33

Google Wave cyj1990 at gmail.com
Thu Nov 24 18:10:12 CET 2011


2011/11/24 <beginners-request at haskell.org>

> Send Beginners mailing list submissions to
>        beginners at haskell.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://www.haskell.org/mailman/listinfo/beginners
> or, via email, send a message with subject or body 'help' to
>        beginners-request at haskell.org
>
> You can reach the person managing the list at
>        beginners-owner at haskell.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Beginners digest..."
>
>
> Today's Topics:
>
>   1.  Basic "data" question (Costello, Roger L.)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 24 Nov 2011 10:43:58 +0000
> From: "Costello, Roger L." <costello at mitre.org>
> Subject: [Haskell-beginners] Basic "data" question
> To: "beginners at haskell.org" <beginners at haskell.org>
> Message-ID:
>        <B5FEE00B53CF054AA8439027E8FE1775181911E9 at IMCMBX04.MITRE.ORG>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi Folks,
>
> I am trying to define a data type for this:
>
>    A Lambda term is one of these:
>        - Variable
>        - Application of a Lambda term to a Lambda term
>        - Abstraction of a Variable in a Lambda term
>
> Here's an example of a Lambda term:
>
> term = Abstraction (Variable X) (Application (Variable X) (Variable Y))
>
> Is there a way to define Lambda term?
>
> Here's an attempt at defining it:
>
> data Var = V | W | X | Y | Z
>
> data Lambda = Variable Var | Application Lambda Lambda | Abstraction
> (Variable Var) Lambda
>
> But that yields the following error:
>
> test.hs:5:71: Not in scope: type constructor or class 'Variable'
>
> Any suggestions would be much appreciated.
>
> /Roger
>
>
>
> ------------------------------
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
> End of Beginners Digest, Vol 41, Issue 33
> *****************************************
>
value constructor  followed by types.  And (Variable Var)  belong to Lambda
type.

Could define like this:
data Lambda var= Variable var | Application (Lambda var) (Lambda var)

var be any types
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111125/2611b2fd/attachment.htm>


More information about the Beginners mailing list