forall a (Ord a => a-> a) -> Int is an illegal type???
Ben Rudiak-Gould
Benjamin.Rudiak-Gould at cl.cam.ac.uk
Thu Feb 9 11:10:12 EST 2006
Brian Hulley wrote:
> I'm puzzled why GHC chooses to create illegal types instead of
> finding the innermost quantification point ie I would think that
>
> (Ord a=> a->a) -> Int
>
> should then "obviously" be shorthand for
>
> (forall a. Ord a=> a->a) -> Int
>
> and surely this could easily be implemented by just prepending "forall a
> b c" onto any context restricting a b c... (?)
I agree that it's strange to add an implicit quantifier and then complain
that it's in the wrong place. I suspect Simon would change this behavior if
you complained about it. My preferred behavior, though, would be to reject
any type that has a forall-less type class constraint anywhere but at the
very beginning. I don't think it's a good idea to expand implicit
quantification. Also, the rule would not be quite as simple as you make it
out to be, since
forall a. (forall b. Foo a b => a -> b) -> Int
is a legal type, for example.
-- Ben
More information about the Glasgow-haskell-users
mailing list