Skip to content

“Illegal type synonym family application in instance” is too strict in the presence of functional dependencies

GHC rejects the following instance, complaining about the use of a type synonym family in the instance head:

type family Fam a
class Multi a b | a -> b
instance Multi (Maybe a) (Fam a)

However, this seems too strict to me, since the second parameter of Multi is determined by a functional dependency. If I tweak the instance slightly to lift the second parameter out of the instance head into an equality constraint, GHC accepts the instance:

instance (b ~ Fam a) => Multi (Maybe a) b

It seems to me that, due to the functional dependency, these two instances are completely equivalent. Therefore, GHC should accept the first instance.

This is similar to an old ticket, #3485 (closed), but that did not involve fundeps, so GHC’s error was correct. I’m pretty sure the addition of functional dependencies changes things, making the two actually equivalent.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information