Skip to content

Cannot use Type Synonym with QuantifiedConstraints in GHC 8.8: "Illegal type synonym family application"

Consider the following simple snippet with three classes, one of which has an associated type synonym:

{-# LANGUAGE FlexibleContexts, QuantifiedConstraints, TypeFamilies #-}
class A c
class B c
class (A (D c) => B (D c)) => C c where
  type D c

GHC 8.6.5 compiles it like a charm, but both GHC 8.8.2 and 8.8.3 fail to compile with the following message:

• Illegal type synonym family application ‘D c’ in instance:
    B (D c)
• In the quantified constraint ‘A (D c) => B (D c)’
  In the context: A (D c) => B (D c)
  While checking the super-classes of class ‘C’
  In the class declaration for ‘C’

Now, I am not sure if this is really a bug or, instead, a correction to the compiler, but I do not actually see why the snippet should fail to compile.

/label needs triage /label ~bug /label TypeFamilies /label QuantifiedConstraints

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