[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell
Subject:    scope of type vars.
From:       Simon L Peyton Jones <simonpj () cs ! glasgow ! ac ! uk>
Date:       1991-03-29 15:15:56
Message-ID: 26994.9103291500 () tutuila ! dcs ! glasgow ! ac ! uk
[Download RAW message or body]

X-Comment1: #############################################################
X-Comment2: #     uk.ac.glasgow.cs has changed to uk.ac.glasgow.dcs     #
X-Comment3: #     If this address does not work please ask your mail    #
X-Comment4: #     administrator to update your NRS & mailer tables.     #
X-Comment5: #############################################################
To: haskell@cs.glasgow.ac.uk
Subject: scope of type vars.
Date: Fri, 29 Mar 91 15:00:29 +0000
From: Simon L Peyton Jones <simonpj@cs.glasgow.ac.uk>
Sender: haskell-request@cs.glasgow.ac.uk


What Phil wants is hard to achieve.  Type-checking the bindings
for an instance declaration gives a type environment.  How can one tell
whether a typing in the environment was infrerred (in which case Phil
would allow it to be more general than requird) or given by an 
explicit signature (in which case he wouldn't).

I've discussed this with him.  We concluded that his proposed modification
is (sadly) not viable.

Simon

===================
From:    Philip Wadler <wadler>
Subject: Re: The scope of type variables 


| 	class Foo a where
| 		op :: a -> Int -> a
| 
| 	instance Foo (c,d,e) where
| 
| 		op :: (c,d,e) -> f -> (c,d,e)
| 		op = ...

I agree with what Simon says, except that declarations
in the instance should be restricted to exactly match the
type implied by the instance declaration.  An application
such as

	op (x,y,z) 'a'

will not type check (the second argument to op must be an
integer), so allowing the signature above is misleading.
It should be made illegal, though

 	instance Foo (c,d,e) where
 		op :: (c,d,e) -> Int -> (c,d,e)
 		op = ...

should be ok, and c,d,e should behave as Simon describes.

- -- P



------- End of Forwarded Message




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic