There's nothing wrong with closed type families. The problem is that not all type functions are injective.
Say, you could have this closed type function:
data X = X
data Y = Y
type family GetTheType a where
GetTheType X = X
GetTheType Y = X
you can't infer the argument type from the result type X
.
Data families are injective, but not closed:
{-# LANGUAGE TypeFamilies #-}
data X = X
data family GetTheType a
data instance GetTheType X = RX
class TC a where
tc :: (GetTheType a) -> Int
instance TC X where
tc RX = 5
main = do
let x = tc RX
print "hello"