Skip to content

No warning on redundant type-family instances

Consider

type family F a

type instance F Int = Int
type instance F Int = Int

Would you not expect a warning about duplicate family instances? But in fact this is just accepted.

Nothing is really wrong here. We just check for compatibility. E.g.

type instance F (a,Int) = a->Bool
type instance F (Int,a) = Int->Bool

This is accepted too; in the F (Int,Int) case both equations yield the same result. But neither equation subsumes the other; we can't delete either.

But if there is a straight overlap, thus

type instance F [a] = Int
type instance F [Int] = Int

it would surely be better to warn, suggesting that you delete the second, redundant instance.

Not a very high priority perhaps.

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