
On Apr 2, 2021, at 8:54 AM, CASANOVA Juan
wrote: I honestly cannot see how it could be hard for the compiler to realize that
instance (Ord a, forall b. Ord b) => Class1 a where fun1 = (<)
and
instance (forall b. (Ord a, Ord b)) => Class1 a where fun1 = (<)
are equivalent. But it doesn't.
Just on this one small point: GHC understands a forall-type as a function, so that (in your second example above) we can produce Ord a and Ord b only once a b has been chosen. Because nothing forces the choice of b, GHC cannot proceed and extract the Ord a constraint. More generally, I don't think there is a good answer for what you want to do, short of using type families instead of functional dependencies. With type families, you can name the new type in terms of the type variables you have in scope. I hope this is helpful! Richard