I'm astonished Hugs allows this.  So far as I know, only GHC allows
rank-2 types.

And GHC only allows them in very specific places (see the manual).
Namely, in data constructor arguments, or in function definition type
signatures.  In the latter, they must be matched by argument on the
left hand side.  
        f :: (forall a. a->a) -> Int
        f x = 3         -- OK
        f = \x->3       -- not ok

Rank 2 types break all the standard typing algorithms.  We can only
do type checking by making rather draconian restrictions.


The error message could be better, I admit.

Simon

| -----Original Message-----
| From: Levent Erkok [mailto:[EMAIL PROTECTED]] 
| Sent: 02 April 2001 10:55
| To: Simon Peyton-Jones
| Subject: hugs/ghc discrepancy, possible bug?
| 
| 
| Hi,
| 
| Sorry to bother you directly but the "bug report" link at 
| www.haskell.org/ghc seems to be down, so I thought I'd 
| directly write to you. The following program:
| 
| ------------------------------------
| module Main(main) where
|  
| import ST
|  
| class X a where
|   x :: (forall s. ST s a) -> IO ()
|   x _ = putStr "done"
|  
| instance X Int
|  
| main = putStr "ok"      
| ------------------------------------
| 
| causes problems in the type-checker of GHC 4.08.1. (Hugs accepts it
| happily.) I can't see why it shouldn't type check, and the 
| error msg didn't help much. So I thought I'd better report it.
|  
| Interestingly, the type checker is satisfied if the default 
| declaration is not used, i.e. if I change the instance declaration to:
| 
| ------------------------------------
| instance X Int where
|   x _ = putStr "done"
| ------------------------------------
| 
| it becomes happy again.
| 
| Cheers,
| 
| -Levent.
| 

_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to