@@ -27,12 +27,12 @@ import GHC.Types.SrcLoc
2727import Ormolu.Utils (notImplemented , showOutputable )
2828
2929-- | Sort and normalize imports.
30- normalizeImports :: [LImportDecl GhcPs ] -> [LImportDecl GhcPs ]
31- normalizeImports =
30+ normalizeImports :: Bool -> [LImportDecl GhcPs ] -> [LImportDecl GhcPs ]
31+ normalizeImports implicitPrelude =
3232 fmap snd
3333 . M. toAscList
3434 . M. fromListWith combineImports
35- . fmap (\ x -> (importId x, g x))
35+ . fmap (\ x -> (importId implicitPrelude x, g x))
3636 where
3737 g :: LImportDecl GhcPs -> LImportDecl GhcPs
3838 g (L l ImportDecl {.. }) =
@@ -118,8 +118,8 @@ instance Ord ImportListInterpretationOrd where
118118 toBool EverythingBut = True
119119
120120-- | Obtain an 'ImportId' for a given import.
121- importId :: LImportDecl GhcPs -> ImportId
122- importId (L _ ImportDecl {.. }) =
121+ importId :: Bool -> LImportDecl GhcPs -> ImportId
122+ importId implicitPrelude (L _ ImportDecl {.. }) =
123123 ImportId
124124 { importIsPrelude = isPrelude,
125125 importIdName = moduleName,
@@ -135,7 +135,7 @@ importId (L _ ImportDecl {..}) =
135135 importLevel = importLevelOf ideclLevelSpec
136136 }
137137 where
138- isPrelude = moduleNameString moduleName == " Prelude"
138+ isPrelude = implicitPrelude && moduleNameString moduleName == " Prelude"
139139 moduleName = unLoc ideclName
140140 importLevelOf = \ case
141141 LevelStylePre l -> Just (ImportDeclLevelOrd l)
0 commit comments