Implicit 'forall' in data declarations
Simon Peyton-Jones
simonpj at microsoft.com
Fri Oct 22 04:20:05 EDT 2010
| > An implicit quantification point is
| > a) the type in a type signature f :: type or
| > b) a type of the form (context => type)
| > if it does not start with an explicit 'forall'
|
...
| How inconvenient would it be to make the above description simpler by
| dropping b) and thus require more explicit 'forall's? I don't know
| what I prefer. I like both convenience and simplicity of explanations
| and cannot judge wich alternative has more convincing arguments in
| this case.
It'd be easy to implement, and now you've forced me to realise that the current rule is quite tricky to explain, I think it'd be an improvement to drop (b).
But it's an unforced change and some programs would require fixing.
Does anyone listening to this thread have an opinion? Just to summarise, Sebastian's proposal is that Haskell's implicit quantification (adding foralls) would occur *only* right at the top of a type signature. The only observable differences in behaviour would, I believe be these
* In a data type declaration
data Foo = MkFoo (Eq a => a -> a)
you'd get an error "a is not in scope", just as you would with
data Foo = MkFoo (a->a)
* Inside an *explicit* forall you would get no *implicit* foralls:
f :: forall a. (Eq b => b->b) -> a -> a
would yield "b is not in scope", whereas at present it behaves like
f :: forall a. (forall b. Eq b => b->b) -> a -> a
I vote for this. In fact I've created a ticket for it.
http://hackage.haskell.org/trac/ghc/ticket/4426
Others listening to this thread: what do you think? Add a comment to the ticket.
Simon
More information about the Glasgow-haskell-users
mailing list