Implicit 'forall' in data declarations
Simon Peyton-Jones
simonpj at microsoft.com
Mon Oct 25 12:00:40 EDT 2010
| > | On a related note, these are also apparently allowed (in 6.10.4):
| > | f :: forall a. (Eq a => a -> a) -> a -> a
| > | -- the Eq context prevents the function from ever being called.
| >
| > That's not true. E.g.
| > f ((==) True) True
| > works fine.
|
| What I meant is that f cannot call its argument.
Oh now I see. Yes, that's true. But it could be hard to work out:
f :: forall a. (C a, D a) => (E [a] => a -> a) -> Int
Can 'f' call its argument? Well, it depends if you can deduce E [a] from (C a, D a). And if this was a local type signature there might be other constraints in scope.
Anyway, it's certainly true that some types are more useful than others (e.g. (forall a. Int -> a) must be the constant bottom function), but I don't think it's fruitful to try to exclude them *as types*.
Simon
More information about the Glasgow-haskell-users
mailing list