@@ -23,6 +23,7 @@ module Language.Haskell.Stylish.Step.Imports
2323 ) where
2424
2525--------------------------------------------------------------------------------
26+ import Control.Applicative ((<|>) )
2627import Control.Monad (forM_ , void , when )
2728import qualified Data.Aeson as A
2829import Data.Foldable (toList )
@@ -507,19 +508,19 @@ printQualified Options{..} padNames stats ldecl = do
507508
508509--------------------------------------------------------------------------------
509510printImport :: Bool -> GHC. IE GHC. GhcPs -> P ()
510- printImport _ (GHC. IEVar _ name) = do
511+ printImport _ (GHC. IEVar _ name _ ) = do
511512 printIeWrappedName name
512- printImport _ (GHC. IEThingAbs _ name) = do
513+ printImport _ (GHC. IEThingAbs _ name _ ) = do
513514 printIeWrappedName name
514- printImport separateLists (GHC. IEThingAll _ name) = do
515+ printImport separateLists (GHC. IEThingAll _ name _ ) = do
515516 printIeWrappedName name
516517 when separateLists space
517518 putText " (..)"
518519printImport _ (GHC. IEModuleContents _ modu) = do
519520 putText " module"
520521 space
521522 putText . GHC. moduleNameString $ GHC. unLoc modu
522- printImport separateLists (GHC. IEThingWith _ name wildcard imps) = do
523+ printImport separateLists (GHC. IEThingWith _ name wildcard imps _ ) = do
523524 printIeWrappedName name
524525 when separateLists space
525526 let ellipsis = case wildcard of
@@ -637,24 +638,24 @@ prepareImportList =
637638 prepareInner :: GHC. IE GHC. GhcPs -> GHC. IE GHC. GhcPs
638639 prepareInner = \ case
639640 -- Simplify `A ()` to `A`.
640- GHC. IEThingWith x n GHC. NoIEWildcard [] -> GHC. IEThingAbs x n
641- GHC. IEThingWith x n w ns ->
642- GHC. IEThingWith x n w (sortBy (compareWrappedName `on` GHC. unLoc) ns)
641+ GHC. IEThingWith x n GHC. NoIEWildcard [] md -> GHC. IEThingAbs x n md
642+ GHC. IEThingWith x n w ns md ->
643+ GHC. IEThingWith x n w (sortBy (compareWrappedName `on` GHC. unLoc) ns) md
643644 ie -> ie
644645
645646 -- Merge two import items, assuming they have the same name.
646647 ieMerge :: GHC. IE GHC. GhcPs -> GHC. IE GHC. GhcPs -> Maybe (GHC. IE GHC. GhcPs )
647- ieMerge l@ (GHC. IEVar _ _) _ = Just l
648- ieMerge _ r@ (GHC. IEVar _ _) = Just r
649- ieMerge (GHC. IEThingAbs _ _) r = Just r
650- ieMerge l (GHC. IEThingAbs _ _) = Just l
651- ieMerge l@ (GHC. IEThingAll _ _) _ = Just l
652- ieMerge _ r@ (GHC. IEThingAll _ _) = Just r
653- ieMerge (GHC. IEThingWith x0 n0 w0 ns0) (GHC. IEThingWith _ _ w1 ns1)
648+ ieMerge l@ (GHC. IEVar _ _ _ ) _ = Just l
649+ ieMerge _ r@ (GHC. IEVar _ _ _ ) = Just r
650+ ieMerge (GHC. IEThingAbs _ _ _ ) r = Just r
651+ ieMerge l (GHC. IEThingAbs _ _ _ ) = Just l
652+ ieMerge l@ (GHC. IEThingAll _ _ _ ) _ = Just l
653+ ieMerge _ r@ (GHC. IEThingAll _ _ _ ) = Just r
654+ ieMerge (GHC. IEThingWith x0 n0 w0 ns0 me0 ) (GHC. IEThingWith _ _ w1 ns1 me1 )
654655 | w0 /= w1 = Nothing
655656 | otherwise = Just $
656657 -- TODO: sort the `ns0 ++ ns1`?
657- GHC. IEThingWith x0 n0 w0 (nubOn GHC. lieWrappedName $ ns0 ++ ns1)
658+ GHC. IEThingWith x0 n0 w0 (nubOn GHC. lieWrappedName $ ns0 ++ ns1) (me0 <|> me1)
658659 ieMerge _ _ = Nothing
659660
660661
0 commit comments