November 2015
Intermediate to advanced
166 pages
3h 14m
English
In 2008, three years after the introduction of associated types, they were subsumed by type families. Associated types are special type families where the type function is attached to a type-class.
In contrast to associated types, we have top-level type-families that are not associated with a type-class, for example:
type family RepF d type instance RepF (List' a) = (RList a)
The type family RepF represents a type function, with each instance declaring a value. Put another way, a type family represents a set of types, and each instance represents a set member.
In our example, GenericF simply uses the top-level type function in its type signatures:
class GenericF d where fromF :: d -> (RepF d) toF :: (RepF d) -> d instance ...
Read now
Unlock full access