Regression in superclass inference between GHC 9.6.0 alpha1 and alpha2
See master ticket #22912 (closed)
{-# LANGUAGE UndecidableInstances #-}
module Foo where
class Foo f
class Foo f => Bar f g
instance Bar f f => Bar f (h k)
This program used to compile with GHC 9.2, 9.4 and 9.6.0-alpha1, but suddenly stopped to compile with 9.6.0-alpha2, which now complains that
programs$ ghc-9.6.0.20230128 -fforce-recomp Foo.hs
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )
Foo.hs:9:10: error: [GHC-39999]
• Could not deduce ‘Foo f’
arising from the superclasses of an instance declaration
from the context: Bar f f
bound by the instance declaration at Foo.hs:9:10-31
Possible fix:
add (Foo f) to the context of the instance declaration
• In the instance declaration for ‘Bar f (h k3)’
|
9 | instance Bar f f => Bar f (h k)
| ^^^^^^^^^^^^^^^^^^^^^^
Is this regression expected? Release notes are silent about it. Migration guide mentions changes to superclass expansion involving type families (BTW this is missing from release notes), but there are no type families in my example and there is no suggestion of "Possible fix: If the constraint looks soluble from a superclass of the instance context, read 'Undecidable instances and loopy superclasses' in the user manual".
If this regression is still an expected consequence of #20666 (closed) / !7050 (merged), please include it in the release notes and amend migration guide, clarifying that regressions are not limited to superclasses involving type families. I suggest to use it instead the current example in the migration guide: this case is clearly much simpler (and much more surprising, if I may say). I would also expect to receive a suggestion to read "Undecidable instances and loopy superclasses", as the migration guide advertises.