Anonymous type instances
I find that commonly I write a
type family (because it doesn't need to be a
data family, and
type families are more flexible), but I find myself writing
data types for some of the instances anyway.
Presently you're forced to use type synonyms for all the instances of a
type family, even if you don't intend to refer to the type by any name other than that of the type family. I find this tiresome:
type family F a type instance F Char = Int newtype FBool = FBool Int type instance F Bool = FBool data FInt = A | B | ... type instance F Int = FInt
I want to write
data instances and
newtype instances for
type families. These proposed constructs would introduce a new type without a name of its own (the only way to refer to it would be through the
type family), just like the current design of
data families. The above code would be roughly equivalent to:
type family F a type instance F Char = Int -- already legal newtype instance F Bool = FBool Int data instance F Int = A | B | ...
I call this idea anonymous type instances but I'm open to suggestions for a snappier name.
Going the other way (writing a
type instance for a
data family) would remain illegal under this proposal.
data family G a type instance G Char = Int -- still illegal
|Component||Compiler (Type checker)|