6 | | * Next: Overlap check for data/newtype instances. |

| 6 | * Overlap check for data/newtype instances. |

| 7 | 1. Check for overlap given a value of type `[FamInst]` (based on a routine that checks two `FamInst`s for overlap). |

| 8 | 2. In `M.hi` store the names of all modules below (and including `M`) that contain family instances. Invariant: if `M` compiles, then none of those modlues have overlaps. |

| 9 | 3. When compiling a new module `K`, union the sets from direct imports, plus `K` itself if it has family instances. If that union is a subset of any of the incoming ones, nothing to do! Otherwise, further checking needed. |

| 10 | 4. Further checking can be brute-force or intelligently to minimise the number of checks. ''Brute-force:'' Take the `FamInst`s of all family-instance modules that are in the complement of the intersection of the sets of family-instance modules contained in each imported module and add `K` if it has imports. Check this whole set using the check from Point (1). ''Intelligently:'' Compute the set of all module pairs that have already been checked for overlap (as they both occur in the family-instance module list of any import) and subtract that from the set of all pairs of visible family-instance modules. These are the critical module pairs. Check any pair of instances coming from two different modules in a critical module pair. |