@@ -49,7 +49,7 @@ compareIdecl (L _ m0) (L _ m1) =
4949sortLies :: [LIE GhcPs] -> [LIE GhcPs]
5050sortLies =
5151 nubBy (\x y -> compareLIE x y == EQ)
52− . sortBy compareLIE
52+ . sortBy compareLIEAll
5353 . fmap (fmap sortThings)
5454
5555-- | Sort imports\/exports inside of 'IEThingWith'.
@@ -59,17 +59,31 @@ sortThings = \case
5959 IEThingWith NoExtField x w (sortBy (compareIewn `on` unLoc) xs) fl
6060 other -> other
6161
62−-- | Compare a pair of located imports or exports.
62+-- | Compare a pair of located imports or exports taking into account
63+-- wildcards.
64+compareLIEAll :: LIE GhcPs -> LIE GhcPs -> Ordering
65+compareLIEAll = f `on` getIewn . unLoc
66+ where
67+ f (x, xall) (y, yall) =
68+ case x `compareIewn` y of
69+ EQ -> xall `compare` yall
70+ ordering -> ordering
71+
72+-- | The same as 'compareLIEAll'.
6373compareLIE :: LIE GhcPs -> LIE GhcPs -> Ordering
64−compareLIE = compareIewn `on` getIewn . unLoc
74+compareLIE = compareIewn `on` fst . getIewn . unLoc
75+
76+-- | Indication whether or not a wildcard is used by an import item.
77+data IEWild = All | NoWild
78+ deriving (Eq, Ord)
6579
6680-- | Project @'IEWrappedName' 'RdrName'@ from @'IE' 'GhcPs'@.
67−getIewn :: IE GhcPs -> IEWrappedName RdrName
81+getIewn :: IE GhcPs -> (IEWrappedName RdrName, IEWild)
6882getIewn = \case
69− IEVar NoExtField x -> unLoc x
70− IEThingAbs NoExtField x -> unLoc x
71− IEThingAll NoExtField x -> unLoc x
72− IEThingWith NoExtField x _ _ _ -> unLoc x
83+ IEVar NoExtField x -> (unLoc x, NoWild)
84+ IEThingAbs NoExtField x -> (unLoc x, NoWild)
85+ IEThingAll NoExtField x -> (unLoc x, All)
86+ IEThingWith NoExtField x _ _ _ -> (unLoc x, NoWild)
7387 IEModuleContents NoExtField _ -> notImplemented "IEModuleContents"
7488 IEGroup NoExtField _ _ -> notImplemented "IEGroup"
7589 IEDoc NoExtField _ -> notImplemented "IEDoc"