Skip to content

Regression in interaction between type families and equality constraints

Summary

I've encountered a regression in GHC 9.2.2 where a flexible instance requiring R ~ e ': some_tail fails to apply even when given the context R ~ e ': F R, where F, R are type families. However, adding the seemingly redundant constraint r ~ R -- where r is an otherwise completely unused polymorphic type variable -- allows the instance to be deduced.

This issue has broken a library of mine, and I haven't yet found a good workaround while preserving the library's current API.

Steps to reproduce

Minimal reproducer. The errors function is rejected with:

    • Could not deduce (Foo Int R) arising from a use of ‘Dict’
      from the context: R ~ (Int : F R)

Environment:

Reproducer tested on GHC 9.2.2 and errors. Compiles without issue on GHC 9.0.2.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information