imp 1.0.3.3 → 1.0.3.4
raw patch · 3 files changed
+56/−21 lines, 3 filesdep ~Cabal-syntaxdep ~basedep ~containersPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: Cabal-syntax, base, containers, ghc
API changes (from Hackage documentation)
+ Imp: emptyImportDecl :: ImportDecl GhcPs
Files
- imp.cabal +5/−5
- source/library/Imp.hs +42/−13
- source/test-suite/Main.hs +9/−3
imp.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: imp-version: 1.0.3.3+version: 1.0.3.4 synopsis: A GHC plugin for automatically importing modules. description: Imp is a GHC plugin for automatically importing modules. category: Plugin@@ -20,7 +20,7 @@ manual: True common library- build-depends: base ^>=4.19.0.0 || ^>=4.20.0.0 || ^>=4.21.0.0+ build-depends: base ^>=4.19.0.0 || ^>=4.20.0.0 || ^>=4.21.0.0 || ^>=4.22.0.0 default-language: Haskell2010 ghc-options: -Weverything@@ -46,10 +46,10 @@ import: library autogen-modules: Paths_imp build-depends:- Cabal-syntax ^>=3.10.1.0 || ^>=3.12.0.0 || ^>=3.14.0.0,- containers ^>=0.6.7 || ^>=0.7,+ Cabal-syntax ^>=3.10.1.0 || ^>=3.12.0.0 || ^>=3.14.0.0 || ^>=3.16.0.0,+ containers ^>=0.6.7 || ^>=0.7 || ^>=0.8, exceptions ^>=0.10.5,- ghc ^>=9.8.1 || ^>=9.10.1 || ^>=9.12.1,+ ghc ^>=9.8.1 || ^>=9.10.1 || ^>=9.12.1 || ^>=9.14.1, transformers ^>=0.6.1, -- cabal-gild: discover source/library
source/library/Imp.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeApplications #-} @@ -152,23 +153,51 @@ Source.Implicit -> Nothing Source.Explicit m -> Just m Just- Hs.ImportDecl- { Hs.ideclExt =- Hs.XImportDeclPass- { Hs.ideclAnn = Hs.noAnn,- Hs.ideclSourceText = SourceText.NoSourceText,- Hs.ideclImplicit = True- },- Hs.ideclName = Hs.noLocA source,+ emptyImportDecl+ { Hs.ideclName = Hs.noLocA source, Hs.ideclPkgQual = maybe PkgQual.NoRawPkgQual (PkgQual.RawPkgQual . PackageName.toStringLiteral) $ Map.lookup (Target.fromModuleName target) packages,- Hs.ideclSource = Hs.NotBoot,- Hs.ideclSafe = False,- Hs.ideclQualified = Hs.QualifiedPre, Hs.ideclAs = if source == target then Nothing- else Just $ Hs.noLocA target,- Hs.ideclImportList = Nothing+ else Just $ Hs.noLocA target }++emptyImportDecl :: Hs.ImportDecl Hs.GhcPs+#if MIN_VERSION_ghc(9, 14, 0)+emptyImportDecl =+ Hs.ImportDecl+ { Hs.ideclExt =+ Hs.XImportDeclPass+ { Hs.ideclAnn = Hs.noAnn,+ Hs.ideclSourceText = SourceText.NoSourceText,+ Hs.ideclImplicit = True+ },+ Hs.ideclName = Hs.noLocA $ Plugin.mkModuleName "Imp.Unknown",+ Hs.ideclPkgQual = PkgQual.NoRawPkgQual,+ Hs.ideclSource = Hs.NotBoot,+ Hs.ideclSafe = False,+ Hs.ideclQualified = Hs.QualifiedPre,+ Hs.ideclAs = Nothing,+ Hs.ideclLevelSpec = Hs.NotLevelled,+ Hs.ideclImportList = Nothing+ }+#else+emptyImportDecl =+ Hs.ImportDecl+ { Hs.ideclExt =+ Hs.XImportDeclPass+ { Hs.ideclAnn = Hs.noAnn,+ Hs.ideclSourceText = SourceText.NoSourceText,+ Hs.ideclImplicit = True+ },+ Hs.ideclName = Hs.noLocA $ Plugin.mkModuleName "Imp.Unknown",+ Hs.ideclPkgQual = PkgQual.NoRawPkgQual,+ Hs.ideclSource = Hs.NotBoot,+ Hs.ideclSafe = False,+ Hs.ideclQualified = Hs.QualifiedPre,+ Hs.ideclAs = Nothing,+ Hs.ideclImportList = Nothing+ }+#endif
source/test-suite/Main.hs view
@@ -131,14 +131,20 @@ parseModule :: (Exception.MonadThrow m) => String -> m (Plugin.Located (Hs.HsModule Hs.GhcPs)) parseModule input = do- let parserOpts = Lexer.mkParserOpts EnumSet.empty emptyDiagOpts [] False False False False- stringBuffer = StringBuffer.stringToStringBuffer input+ let stringBuffer = StringBuffer.stringToStringBuffer input realSrcLoc = Plugin.mkRealSrcLoc (Plugin.mkFastString "<interactive>") 1 1- pState = Lexer.initParserState parserOpts stringBuffer realSrcLoc+ pState = Lexer.initParserState emptyParserOpts stringBuffer realSrcLoc parseResult = Lexer.unP Parser.parseModule pState case parseResult of Lexer.PFailed _ -> Exception.throwM $ InvalidInput input Lexer.POk _ lHsModule -> pure lHsModule++emptyParserOpts :: Lexer.ParserOpts+#if MIN_VERSION_ghc(9, 14, 0)+emptyParserOpts = Lexer.mkParserOpts EnumSet.empty emptyDiagOpts False False False False+#else+emptyParserOpts = Lexer.mkParserOpts EnumSet.empty emptyDiagOpts [] False False False False+#endif emptyDiagOpts :: Error.DiagOpts #if MIN_VERSION_ghc(9, 8, 1)