
I'm curious as to why GHC doesn't accept the following (contrived) module: {-# LANGUAGE ImplicitParams, RankNTypes #-} f :: (?g :: (forall a . a -> a)) => a -> a f = ?g The error message is: Illegal polymorphic or qualified type: forall a. a -> a In the type signature for `f': f :: ?g :: (forall a. a -> a) => a -> a It's not a big deal since one can wrap the polymorphism in a newtype, but it's somewhat unexpected. Roman

Generally speaking ALL constraints (class constraints, equality constraints, implicit parameters) range only over monotypes. The apparatus should extend to polymorphic types, be it's somewhat uncharted territory. I doubt there'd be much problem in the case of implicit parameters. In short, in principle it might be possible, but it would take a little careful thought and I have too few careful-thought electrons available right now. Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of Roman Cheplyaka | Sent: 20 March 2013 08:58 | To: glasgow-haskell-users@haskell.org | Subject: Polymorphic implicit parameters | | I'm curious as to why GHC doesn't accept the following (contrived) | module: | | {-# LANGUAGE ImplicitParams, RankNTypes #-} | | f :: (?g :: (forall a . a -> a)) => a -> a | f = ?g | | The error message is: | | Illegal polymorphic or qualified type: forall a. a -> a | In the type signature for `f': | f :: ?g :: (forall a. a -> a) => a -> a | | It's not a big deal since one can wrap the polymorphism in a newtype, | but it's somewhat unexpected. | | Roman | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

That makes sense, thank you.
Roman
* Simon Peyton-Jones
Generally speaking ALL constraints (class constraints, equality constraints, implicit parameters) range only over monotypes.
The apparatus should extend to polymorphic types, be it's somewhat uncharted territory. I doubt there'd be much problem in the case of implicit parameters.
In short, in principle it might be possible, but it would take a little careful thought and I have too few careful-thought electrons available right now.
Simon
| -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of Roman Cheplyaka | Sent: 20 March 2013 08:58 | To: glasgow-haskell-users@haskell.org | Subject: Polymorphic implicit parameters | | I'm curious as to why GHC doesn't accept the following (contrived) | module: | | {-# LANGUAGE ImplicitParams, RankNTypes #-} | | f :: (?g :: (forall a . a -> a)) => a -> a | f = ?g | | The error message is: | | Illegal polymorphic or qualified type: forall a. a -> a | In the type signature for `f': | f :: ?g :: (forall a. a -> a) => a -> a | | It's not a big deal since one can wrap the polymorphism in a newtype, | but it's somewhat unexpected. | | Roman | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (2)
-
Roman Cheplyaka
-
Simon Peyton-Jones