Anchor type family instances deterministically
authorBartosz Nitka <niteria@gmail.com>
Mon, 31 Aug 2015 15:10:34 +0000 (16:10 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 31 Aug 2015 15:10:34 +0000 (16:10 +0100)
Summary:
This is very similar to D1073. It makes type family instances to be
attached to a binding with a least `OccName`, therefore not depending on `Unique` ordering.

Test Plan:
* this makes `Language.Haskell.Exts.SrcLoc` deterministic
* ./validate

Reviewers: simonmar, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1192

GHC Trac Issues: #4012

compiler/iface/MkIface.hs

index 697972a..f594181 100644 (file)
@@ -1853,13 +1853,8 @@ famInstToIfaceFamInst (FamInst { fi_axiom    = axiom,
 
     orph | is_local fam_decl
          = NotOrphan (nameOccName fam_decl)
-
-         | not (isEmptyNameSet lhs_names)
-         = NotOrphan (nameOccName (head (nameSetElems lhs_names)))
-
-
          | otherwise
-         = IsOrphan
+         = chooseOrphanAnchor $ nameSetElems lhs_names
 
 --------------------------
 toIfaceLetBndr :: Id -> IfaceLetBndr