X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FbasicTypes%2FRdrName.lhs;h=e84a391aeafd44fa173ae8347ad06d3b3e4114a5;hb=0f098b75c81e884a445654b2fe097ee247436ee1;hp=d858dbc1833784c894135846ab2647e0dbd130a1;hpb=8a40130c7ab9c175c707e55060ec8d441851e82a;p=ghc-hetmet.git diff --git a/ghc/compiler/basicTypes/RdrName.lhs b/ghc/compiler/basicTypes/RdrName.lhs index d858dbc..e84a391 100644 --- a/ghc/compiler/basicTypes/RdrName.lhs +++ b/ghc/compiler/basicTypes/RdrName.lhs @@ -86,7 +86,7 @@ data RdrName -- (b) when converting names to the RdrNames in IfaceTypes -- Here an Exact RdrName always contains an External Name -- (Internal Names are converted to simple Unquals) - -- (c) possibly, by the meta-programming stuff + -- (c) by Template Haskell, when TH has generated a unique name \end{code} @@ -234,21 +234,28 @@ instance Ord RdrName where a >= b = case (a `compare` b) of { LT -> False; EQ -> True; GT -> True } a > b = case (a `compare` b) of { LT -> False; EQ -> False; GT -> True } - -- Unqual < Qual < Orig - -- We always convert Exact to Orig before comparing - compare (Exact n1) (Exact n2) | n1==n2 = EQ -- Short cut - | otherwise = nukeExact n1 `compare` nukeExact n2 - compare (Exact n1) n2 = nukeExact n1 `compare` n2 - compare n1 (Exact n2) = n1 `compare` nukeExact n2 - - - compare (Qual m1 o1) (Qual m2 o2) = (o1 `compare` o2) `thenCmp` (m1 `compare` m2) - compare (Orig m1 o1) (Orig m2 o2) = (o1 `compare` o2) `thenCmp` (m1 `compare` m2) + -- Exact < Unqual < Qual < Orig + -- [Note: Apr 2004] We used to use nukeExact to convert Exact to Orig + -- before comparing so that Prelude.map == the exact Prelude.map, but + -- that meant that we reported duplicates when renaming bindings + -- generated by Template Haskell; e.g + -- do { n1 <- newName "foo"; n2 <- newName "foo"; + -- } + -- I think we can do without this conversion + compare (Exact n1) (Exact n2) = n1 `compare` n2 + compare (Exact n1) n2 = LT + + compare (Unqual _) (Exact _) = GT compare (Unqual o1) (Unqual o2) = o1 `compare` o2 - compare (Unqual _) _ = LT + + compare (Qual _ _) (Exact _) = GT + compare (Qual _ _) (Unqual _) = GT + compare (Qual m1 o1) (Qual m2 o2) = (o1 `compare` o2) `thenCmp` (m1 `compare` m2) compare (Qual _ _) (Orig _ _) = LT - compare _ _ = GT + + compare (Orig m1 o1) (Orig m2 o2) = (o1 `compare` o2) `thenCmp` (m1 `compare` m2) + compare (Orig _ _) _ = GT \end{code}