Version 8 (modified by chak, 11 years ago) (diff)


Type Functions: Interface

Representation of family instances

The IfaceSyn.IfaceData variant of IfaceDecl contains a new ifFamInst :: Maybe (IfaceTyCon, [IfaceType]) field that distinguishes ordinary data/newtype declarations from family instances. In the latter case, the (IfaceTyCon, [IfaceType]) value gives the family instance type. In addition, each family instance is represented by a value of type IfaceFamInst that includes the instances rough match (i.e., name of the family type and a [Maybe IfaceTyCon] value that gives the outermost type constructor of each index argument for that instance) and refers to the type declaration for full details (as a class instance does with its dfun).

Moreover, much like class instances, family instance heads of a module are collected in the new mi_fam_insts :: [IfaceFamInst] field of HscTypes.ModIface. This allows to enter the rough matches into the ModGuts, when reading the interface, without having to parse the full tycon that represents the instance yet. This in turn avoids pulling in everything that hangs of that tycon.