Send Beginners mailing list submissions to
        [email protected]

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
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Possible to type a function to a particular  constructor?
      (Jan Jakubuv)


----------------------------------------------------------------------

Message: 1
Date: Mon, 3 May 2010 12:57:34 +0100
From: Jan Jakubuv <[email protected]>
Subject: Re: [Haskell-beginners] Possible to type a function to a
        particular      constructor?
To: Ken Overton <[email protected]>
Cc: "[email protected]" <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi Ken,

You can additionally try to change your definition of lambda-terms to use
parametric types as follows.

    data T var = V var | A (T var) (T var) | L var (T var)

Then you can write `freev` with the following type.

    freev :: T var -> [var]

Sincerely,
    jan.


On Sun, May 02, 2010 at 09:54:11AM -0400, Ken Overton wrote:
> 
> Hi fellow beginners (and everyone else),
> 
> As an exercise, I'm implementing a simple, untyped lambda calculus:
> 
> -- a term is a variable, an application, or abstraction (lambda)
> data T = V String | A (T) (T) | L String (T)
>       deriving (Eq)
> 
> So I'm writing a function that returns a list of all the free variables in a 
> term and descendants. I can only get it to compile with type:
> 
>     freev :: T -> [T]
> 
> It'd be nice for the type of that function to be restricted to just variables 
> like:
> 
>     freev :: T -> [V String] -- compile error: "Not in scope: type 
> constructor or class `V'"
> 
> Is there some way to express that?  The error seems to suggest maybe haskell 
> could do it if I'd just say it correctly.  I mean, isn't "V String" a type 
> constructor?
> 
> Thanks,
> 
> kov
> 
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners


-- 
Heriot-Watt University is a Scottish charity
registered under charity number SC000278.



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 23, Issue 3
****************************************

Reply via email to