module-management 0.20.4 → 0.21
raw patch · 17 files changed
+98/−68 lines, 17 filesdep ~haskell-src-exts
Dependency ranges changed: haskell-src-exts
Files
- Language/Haskell/Modules.hs +7/−7
- Language/Haskell/Modules/Imports.hs +11/−3
- Language/Haskell/Modules/Params.hs +3/−3
- Language/Haskell/Modules/Util/SrcLoc.hs +5/−1
- Language/Haskell/Modules/Util/Symbols.hs +14/−6
- Tests/Fold.hs +9/−9
- Tests/Imports.hs +8/−8
- Tests/Main.hs +2/−2
- Tests/Merge.hs +7/−7
- Tests/Split.hs +11/−11
- Tests/Symbols.hs +5/−1
- changelog +6/−0
- module-management.cabal +3/−3
- scripts/CLI.hs +2/−2
- scripts/CleanModules.hs +2/−2
- testdata/imports7-expected/CLI.hs +2/−2
- testdata/imports7/CLI.hs +1/−1
Language/Haskell/Modules.hs view
@@ -11,7 +11,7 @@ -- -- These are the important entry points: ----- * 'runCleanT' - Sets up the environment for splitting and merging.+-- * 'runImportsT' - Sets up the environment for splitting and merging. -- These operations require updates to be made to all the modules -- that import the modules being split or merged, so this -- environment tracks the creation and removal of modules. This@@ -41,13 +41,13 @@ -- * Use 'findHsFiles' and 'cleanImports' to clean up the import lists -- of all the modules under @./Language@: ----- @findHsFiles [\"Language\", \"Tests.hs\", \"Tests\"] >>= runCleanT . cleanImports@+-- @findHsFiles [\"Language\", \"Tests.hs\", \"Tests\"] >>= runImportsT . cleanImports@ -- -- * Split the module @Language.Haskell.Modules.Common@, and then -- merge two of the declarations back in: -- -- @:m +Language.Haskell.Exts.Syntax--- findHsModules [\"Language\", \"Tests.hs\", \"Tests\"] >>= \\ modules -> runCleanT $+-- findHsModules [\"Language\", \"Tests.hs\", \"Tests\"] >>= \\ modules -> runImportsT $ -- mapM putModule modules >> -- splitModuleDecls \"Language\/Haskell\/Modules\/Common.hs\" >> -- mergeModules [ModuleName \"Language.Haskell.Modules.Common.WithCurrentDirectory\",@@ -58,7 +58,7 @@ -- @Tmp@ is used because using existing modules for a split is not allowed. -- The exception to this is that you can leave declarations in the original module. ----- @findHsModules [\"Language\", \"Tests.hs\", \"Tests\"] >>= \\ modules -> runCleanT $+-- @findHsModules [\"Language\", \"Tests.hs\", \"Tests\"] >>= \\ modules -> runImportsT $ -- mapM putModule modules >> -- splitModule (\\ n -> if elem n [Just (Ident \"ModuleResult\"), Just (Ident \"doResult\")] -- then ModuleName \"Tmp\"@@ -69,7 +69,7 @@ -- -- * Split a module where one of the result modules needs to import the instances: ----- @runCleanT $+-- @runImportsT $ -- putModule (ModuleName \"Main\") >> -- extraImport (ModuleName \"Main.GetPasteById\") (ModuleName \"Main.Instances\") >> -- splitModuleDecls \"Main.hs\"@@@ -85,7 +85,7 @@ -- * Runtime environment , MonadClean , CleanT- , runCleanT+ , runImportsT , putModule , findModule , modifyDryRun@@ -114,7 +114,7 @@ import Language.Haskell.Modules.Imports (cleanImports) import Language.Haskell.Modules.Merge (mergeModules) import Language.Haskell.Modules.ModuVerse (findModule, modifyExtensions, putModule)-import Language.Haskell.Modules.Params (CleanT, extraImport, modifyDryRun, modifyHsFlags, modifyRemoveEmptyImports, modifyTestMode, MonadClean, runCleanT)+import Language.Haskell.Modules.Params (CleanT, extraImport, modifyDryRun, modifyHsFlags, modifyRemoveEmptyImports, modifyTestMode, MonadClean, runImportsT) import Language.Haskell.Modules.SourceDirs (modifyDirs, modulePathBase, SourceDirs(putDirs)) import Language.Haskell.Modules.Split (defaultSymbolToModule, splitModule, splitModuleDecls, splitModuleBy) import Language.Haskell.Modules.Util.QIO (noisily, quietly)
Language/Haskell/Modules/Imports.hs view
@@ -50,7 +50,7 @@ cleanBuildImports :: LocalBuildInfo -> IO () cleanBuildImports lbi = mapM (toFilePath srcDirs) (maybe [] exposedModules (library (localPkgDescr lbi))) >>= \ libPaths ->- runCleanT (Distribution.Simple.LocalBuildInfo.scratchDir lbi) $ mapM_ clean (libPaths ++ exePaths)+ runImportsT (Distribution.Simple.LocalBuildInfo.scratchDir lbi) $ mapM_ clean (libPaths ++ exePaths) where clean path = cleanImports path >>= liftIO . putStrLn . either show (\ text -> path ++ ": " ++ maybe "no changes" (\ _ -> " updated") text) exePaths = map modulePath (executables (localPkgDescr lbi))@@ -249,21 +249,29 @@ else s where n = case s of-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) (A.IVar _ _ x) -> x #else (A.IVar _ x) -> x #endif+#if MIN_VERSION_haskell_src_exts(1,17,0)+ (A.IAbs _ _ x) -> x+#else (A.IAbs _ x) -> x+#endif (A.IThingAll _ x) -> x (A.IThingWith _ x _) -> x s' = case s of-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) (A.IVar l _ x) -> A.IThingAll l x #else (A.IVar l x) -> A.IThingAll l x #endif+#if MIN_VERSION_haskell_src_exts(1,17,0)+ (A.IAbs l _ x) -> A.IThingAll l x+#else (A.IAbs l x) -> A.IThingAll l x+#endif (A.IThingWith l x _) -> A.IThingAll l x (A.IThingAll _ _) -> s
Language/Haskell/Modules/Params.hs view
@@ -7,7 +7,7 @@ , CleanT , MonadClean(getParams, putParams) , modifyParams- , runCleanT+ , runImportsT , markForDelete , modifyRemoveEmptyImports , modifyHsFlags@@ -94,8 +94,8 @@ -- | Create the environment required to do import cleaning and module -- splitting/merging. This environment, @StateT Params m a@, is an -- instance of 'MonadClean'.-runCleanT :: (MonadIO m, MonadBaseControl IO m) => CleanT m a -> m a-runCleanT action =+runImportsT :: (MonadIO m, MonadBaseControl IO m) => CleanT m a -> m a+runImportsT action = withTempDirectory "." "hmm" $ \ scratch -> do (result, params) <- runStateT action (Params {scratchDir = scratch, dryRun = False,
Language/Haskell/Modules/Util/SrcLoc.hs view
@@ -83,12 +83,16 @@ spanInfo (A.ExportSpecList x _) = x instance HasSpanInfo ExportSpec where-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) spanInfo (A.EVar x _ _) = x #else spanInfo (A.EVar x _) = x #endif+#if MIN_VERSION_haskell_src_exts(1,17,0)+ spanInfo (A.EAbs x _ _) = x+#else spanInfo (A.EAbs x _) = x+#endif spanInfo (A.EThingAll x _) = x spanInfo (A.EThingWith x _ _) = x spanInfo (A.EModuleContents x _) = x
Language/Haskell/Modules/Util/Symbols.hs view
@@ -170,22 +170,30 @@ -- Something imported can be exported instance FoldDeclared (A.ImportSpec l) where-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) foldDeclared f r (A.IVar _ _ name) = foldDeclared f r name #else foldDeclared f r (A.IVar _ name) = foldDeclared f r name #endif+#if MIN_VERSION_haskell_src_exts(1,17,0)+ foldDeclared f r (A.IAbs _ _ name) = foldDeclared f r name+#else foldDeclared f r (A.IAbs _ name) = foldDeclared f r name+#endif foldDeclared f r (A.IThingAll _ name) = foldDeclared f r name foldDeclared f r (A.IThingWith _ name _) = foldDeclared f r name instance FoldDeclared (A.ExportSpec l) where-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) foldDeclared f r (A.EVar _ _ name) = foldDeclared f r name #else foldDeclared f r (A.EVar _ name) = foldDeclared f r name #endif+#if MIN_VERSION_haskell_src_exts(1,17,0)+ foldDeclared f r (A.EAbs _ _ name) = foldDeclared f r name+#else foldDeclared f r (A.EAbs _ name) = foldDeclared f r name+#endif foldDeclared f r (A.EThingAll _ name) = foldDeclared f r name foldDeclared f r (A.EThingWith _ name _) = foldDeclared f r name foldDeclared _ r (A.EModuleContents _ _) = r -- This probably won't work correctly@@ -204,7 +212,7 @@ exports :: (FoldDeclared a, FoldMembers a) => a -> [S.ExportSpec] exports x = case (justs (symbols x), justs (members x)) of-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) ([n], []) -> [S.EVar S.NoNamespace (S.UnQual n)] #else ([n], []) -> [S.EVar (S.UnQual n)]@@ -212,7 +220,7 @@ ([n], ms) -> [S.EThingWith (S.UnQual n) (sort (map S.VarName ms))] ([], []) -> [] ([], _) -> error "exports: members with no top level name"-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) (ns, []) -> map (S.EVar S.NoNamespace . S.UnQual) ns #else (ns, []) -> map (S.EVar . S.UnQual) ns@@ -221,7 +229,7 @@ imports :: (FoldDeclared a, FoldMembers a) => a -> [S.ImportSpec] imports x = case (justs (symbols x), justs (members x)) of-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) ([n], []) -> [S.IVar S.NoNamespace n] #else ([n], []) -> [S.IVar n]@@ -229,7 +237,7 @@ ([n], ms) -> [S.IThingWith n (sort (map S.VarName ms))] ([], []) -> [] ([], _ms) -> error "exports: members with no top level name"-#if MIN_VERSION_haskell_src_exts(1,16,0)+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0) (ns, []) -> map (S.IVar S.NoNamespace) ns #else (ns, []) -> map S.IVar ns
Tests/Fold.hs view
@@ -13,7 +13,7 @@ import Language.Haskell.Modules.Common (withCurrentDirectory) import Language.Haskell.Modules.Fold (echo, echo2, foldDecls, foldModule) import Language.Haskell.Modules.ModuVerse (ModuleInfo(..), parseModule)-import Language.Haskell.Modules.Params (runCleanT)+import Language.Haskell.Modules.Params (runImportsT) import Language.Haskell.Modules.SourceDirs (pathKey, APath(..)) import Language.Haskell.Modules.Util.SrcLoc (HasSpanInfo(..), makeTree) import Test.HUnit (assertEqual, Test(TestList, TestCase, TestLabel))@@ -28,7 +28,7 @@ test1 = TestLabel "test1" $ TestCase $ withCurrentDirectory "testdata/debian" $ do let path = APath "Debian/Repo/Slice.hs"- mi <- runCleanT $ pathKey path >>= parseModule+ mi <- runImportsT $ pathKey path >>= parseModule let (output, original) = test mi assertEqual "echo" original output where@@ -39,7 +39,7 @@ test1b = TestLabel "test1b" $ TestCase $ withCurrentDirectory "testdata/debian" $ do let path = APath "Debian/Repo/Slice.hs"- mi <- runCleanT $ pathKey path >>= parseModule+ mi <- runImportsT $ pathKey path >>= parseModule let output = parseTestOutput mi assertEqual "echo" mempty (Seq.filter (\ (a, b) -> a /= b) (Seq.zip expected output)) where@@ -121,7 +121,7 @@ test3 = TestLabel "test3" $ TestCase $ withCurrentDirectory "testdata" $ do let path = APath "Equal.hs"- mi <- runCleanT $ pathKey path >>= parseModule+ mi <- runImportsT $ pathKey path >>= parseModule let (output, original) = test mi assertEqual "echo" original output where@@ -132,7 +132,7 @@ fold3b = TestLabel "fold3b" $ TestCase $ withCurrentDirectory "testdata" $ do let path = APath "fold3b/Main.hs"- mi <- runCleanT $ pathKey path >>= parseModule+ mi <- runImportsT $ pathKey path >>= parseModule let (output, original) = test mi assertEqual "echo" original output where@@ -143,7 +143,7 @@ fold3c = TestLabel "fold3c" $ TestCase $ do let path = APath "testdata/fold9.hs"- mi <- runCleanT $ pathKey path >>= parseModule+ mi <- runImportsT $ pathKey path >>= parseModule let (output, original) = test mi assertEqual "echo" original output where@@ -154,7 +154,7 @@ test5 = TestLabel "fold5" $ TestCase $ do let path = APath "testdata/fold5.hs" -- "testdata/logic/Data/Logic/Classes/Literal.hs"- mi <- runCleanT $ pathKey path >>= parseModule+ mi <- runImportsT $ pathKey path >>= parseModule -- let actual = map f (adjustSpans text comments (spans m)) -- assertEqual "spans" original actual let actual = foldDecls (\ _ a b c r -> r ++ [(a, b, c)]) (\ s r -> r ++ [("", s, "")]) mi []@@ -168,7 +168,7 @@ test5b = TestLabel "test5b" $ TestCase $ do let path = APath "testdata/logic/Data/Logic/Classes/Literal.hs"- mi <- runCleanT $ pathKey path >>= parseModule+ mi <- runImportsT $ pathKey path >>= parseModule let actual = foldDecls (\ _ a b c r -> r ++ [(a, b, c)]) (\ s r -> r ++ [("", s, "")]) mi [] assertEqual "spans" expected actual where@@ -227,7 +227,7 @@ test7 :: Test test7 = TestCase $- do mi <- runCleanT $ pathKey (APath "testdata/Fold7.hs") >>= parseModule+ do mi <- runImportsT $ pathKey (APath "testdata/Fold7.hs") >>= parseModule let actual = foldModule (\ s r -> r |> (s, "", "")) (\ _ b s a r -> r |> (b, s, a)) (\ _ b s a r -> r |> (b, s, a))
Tests/Imports.hs view
@@ -3,7 +3,7 @@ import qualified Language.Haskell.Exts.Syntax as S (ModuleName(ModuleName))-import Language.Haskell.Modules (cleanImports, modifyExtensions, modifyTestMode, modulePathBase, putDirs, runCleanT, withCurrentDirectory)+import Language.Haskell.Modules (cleanImports, modifyExtensions, modifyTestMode, modulePathBase, putDirs, runImportsT, withCurrentDirectory) import Language.Haskell.Modules.Params (modifyParams, Params(hsFlags)) import Language.Haskell.Modules.SourceDirs (RelPath(unRelPath)) import Language.Haskell.Modules.Util.Test (diff, rsync)@@ -31,7 +31,7 @@ (do rsync "testdata/debian" "tmp" let name = S.ModuleName "Debian.Repo.PackageIndex" let base = modulePathBase "hs" name- _ <- withCurrentDirectory "tmp" $ (runCleanT (cleanImports [unRelPath base]))+ _ <- withCurrentDirectory "tmp" $ (runImportsT (cleanImports [unRelPath base])) (code, out, err) <- readProcessWithExitCode "diff" ["-ru", "testdata/debian" </> unRelPath base, "tmp" </> unRelPath base] "" assertEqual "cleanImports" (ExitFailure 1,@@ -65,7 +65,7 @@ (do rsync "testdata/debian" "tmp" let name = S.ModuleName "Debian.Repo.PackageIndex" base = modulePathBase "hs" name- _ <- withCurrentDirectory "tmp" (runCleanT (cleanImports [unRelPath base]))+ _ <- withCurrentDirectory "tmp" (runImportsT (cleanImports [unRelPath base])) (code, out, err) <- readProcessWithExitCode "diff" ["-ru", "testdata/debian" </> unRelPath base, "tmp" </> unRelPath base] "" assertEqual "cleanImports" (ExitSuccess, "", "") (code, out, err)) @@ -74,7 +74,7 @@ test3 = TestLabel "imports3" $ TestCase (rsync "testdata/imports3" "tmp" >>- runCleanT (putDirs ["tmp"] >> cleanImports ["tmp/NotMain.hs"]) >>+ runImportsT (putDirs ["tmp"] >> cleanImports ["tmp/NotMain.hs"]) >> assertEqual "module name" () ()) -- | Preserve imports with a "hiding" clause@@ -82,7 +82,7 @@ test4 = TestLabel "imports4" $ TestCase (rsync "testdata/imports4" "tmp" >>- runCleanT (putDirs ["tmp"] >> cleanImports ["tmp/Hiding.hs"]) >>+ runImportsT (putDirs ["tmp"] >> cleanImports ["tmp/Hiding.hs"]) >> -- Need to check the text of Hiding.hs, but at least this verifies that there was no crash assertEqual "module name" () ()) @@ -91,7 +91,7 @@ test5 = TestLabel "imports5" $ TestCase (do _ <- rsync "testdata/imports5" "tmp"- _ <- runCleanT+ _ <- runImportsT (putDirs ["tmp"] >> modifyExtensions (++ map nameToExtension [StandaloneDeriving, TypeSynonymInstances, FlexibleInstances]) >> cleanImports ["tmp/Deriving.hs"])@@ -116,7 +116,7 @@ test6 = TestLabel "imports6" $ TestCase (do _ <- rsync "testdata/imports6" "tmp"- _ <- withCurrentDirectory "tmp" (runCleanT (modifyTestMode (const True) >> cleanImports ["EndComment.hs"]))+ _ <- withCurrentDirectory "tmp" (runImportsT (modifyTestMode (const True) >> cleanImports ["EndComment.hs"])) (_, out, _) <- readProcessWithExitCode "diff" ["-ru", "imports6-expected", "tmp"] "" assertEqual "comment at end" "" out) @@ -125,7 +125,7 @@ test7 = TestLabel "imports7" $ TestCase (do _ <- rsync "testdata/imports7" "tmp"- _ <- withCurrentDirectory "tmp" (runCleanT (putDirs [".", ".."] >>+ _ <- withCurrentDirectory "tmp" (runImportsT (putDirs [".", ".."] >> modifyParams (\ m -> m {hsFlags = "-DMIN_VERSION_haskell_src_exts(a,b,c)=1" : hsFlags m}) >> modifyTestMode (const True) >> cleanImports ["CLI.hs"]))
Tests/Main.hs view
@@ -13,7 +13,7 @@ #endif import Language.Haskell.Exts.SrcLoc (SrcSpanInfo) import Language.Haskell.Exts.Syntax (ModuleName(ModuleName))-import Language.Haskell.Modules (CleanT, mergeModules, modifyExtensions, MonadClean, noisily, putModule, runCleanT, splitModuleDecls, withCurrentDirectory)+import Language.Haskell.Modules (CleanT, mergeModules, modifyExtensions, MonadClean, noisily, putModule, runImportsT, splitModuleDecls, withCurrentDirectory) import Language.Haskell.Modules.Util.Test (diff', logicModules, rsync) import System.Exit (ExitCode(ExitSuccess, ExitFailure), exitWith) import System.Process (system)@@ -80,7 +80,7 @@ logictest s f = TestLabel s $ TestCase $ do _ <- rsync "testdata/logic" "tmp"- _ <- withCurrentDirectory "tmp" $ runCleanT $ noisily $ f (map ModuleName logicModules)+ _ <- withCurrentDirectory "tmp" $ runImportsT $ noisily $ f (map ModuleName logicModules) (code, out, err) <- diff' ("testdata/" ++ s ++ "-expected") "tmp" let out' = unlines (filter (not . isPrefixOf "Binary files") . map (takeWhile (/= '\t')) $ (lines out)) assertEqual s (ExitSuccess, "", "") (code, out', err)
Tests/Merge.hs view
@@ -2,7 +2,7 @@ import Control.Monad as List (mapM_) import qualified Language.Haskell.Exts.Syntax as S (ModuleName(ModuleName))-import Language.Haskell.Modules (mergeModules, modifyTestMode, noisily, putDirs, putModule, runCleanT, withCurrentDirectory, findHsModules)+import Language.Haskell.Modules (mergeModules, modifyTestMode, noisily, putDirs, putModule, runImportsT, withCurrentDirectory, findHsModules) import Language.Haskell.Modules.Util.Test (diff, repoModules, rsync) import System.Exit (ExitCode(ExitSuccess, ExitFailure)) import Test.HUnit (assertEqual, Test(TestCase, TestList))@@ -14,7 +14,7 @@ test1 = TestCase $ do _ <- rsync "testdata/debian" "tmp"- _result <- runCleanT $ noisily $ noisily $ noisily $+ _result <- runImportsT $ noisily $ noisily $ noisily $ do putDirs ["tmp"] modifyTestMode (const True) mapM_ (putModule . S.ModuleName) repoModules@@ -28,7 +28,7 @@ test2 = TestCase $ do _ <- rsync "testdata/debian" "tmp"- _result <- runCleanT $+ _result <- runImportsT $ do putDirs ["tmp"] modifyTestMode (const True) mapM_ (putModule . S.ModuleName) repoModules@@ -43,7 +43,7 @@ TestCase $ do _ <- rsync "testdata/debian" "tmp" _result <- withCurrentDirectory "tmp" $- runCleanT $+ runImportsT $ do modifyTestMode (const True) mapM_ (putModule . S.ModuleName) repoModules mergeModules@@ -58,7 +58,7 @@ test4 = TestCase $ do _ <- rsync "testdata/merge4" "tmp"- _ <- withCurrentDirectory "tmp" $ runCleanT $+ _ <- withCurrentDirectory "tmp" $ runImportsT $ do mapM_ (putModule . S.ModuleName) ["In1", "In2", "M1"] mergeModules [S.ModuleName "In1", S.ModuleName "In2"] (S.ModuleName "Out") (code, out, err) <- diff "testdata/merge4-expected" "tmp"@@ -68,7 +68,7 @@ test5 = TestCase $ do _ <- rsync "testdata/merge5" "tmp"- _ <- withCurrentDirectory "tmp" $ runCleanT $ noisily $ noisily $ noisily $+ _ <- withCurrentDirectory "tmp" $ runImportsT $ noisily $ noisily $ noisily $ do modifyTestMode (const True) List.mapM_ (putModule . S.ModuleName) ["Apt.AptIO", "Apt.AptIOT", "Apt.AptState",@@ -85,7 +85,7 @@ do _ <- rsync "testdata/merge6" "tmp" _ <- withCurrentDirectory "tmp" $ findHsModules ["Test.hs", "A.hs", "B/C.hs", "B/D.hs"] >>= \ modules ->- runCleanT $ noisily $ noisily $ noisily $+ runImportsT $ noisily $ noisily $ noisily $ do mapM_ putModule modules mergeModules [S.ModuleName "B.C", S.ModuleName "A"] (S.ModuleName "A") (code, out, err) <- diff "testdata/merge6-expected" "tmp"
Tests/Split.hs view
@@ -2,7 +2,7 @@ import Control.Monad as List (mapM_) import qualified Language.Haskell.Exts.Syntax as S (ModuleName(..), Name(Ident))-import Language.Haskell.Modules (modifyTestMode, noisily, putDirs, putModule, runCleanT, splitModule, splitModuleDecls, withCurrentDirectory, findHsModules, extraImport)+import Language.Haskell.Modules (modifyTestMode, noisily, putDirs, putModule, runImportsT, splitModule, splitModuleDecls, withCurrentDirectory, findHsModules, extraImport) import Language.Haskell.Modules.Util.Test (diff, repoModules, rsync) import Prelude hiding (writeFile) import System.Exit (ExitCode(ExitSuccess, ExitFailure))@@ -18,7 +18,7 @@ split1 = TestCase $ do _ <- rsync "testdata/debian" "tmp"- _ <- runCleanT $ noisily $ noisily $+ _ <- runImportsT $ noisily $ noisily $ do putDirs ["tmp"] mapM_ putModule (map S.ModuleName repoModules) splitModuleDecls "tmp/Debian/Repo/Package.hs"@@ -29,7 +29,7 @@ split2a = TestCase $ do _ <- rsync "testdata/split2" "tmp"- _ <- runCleanT $ noisily $ noisily $+ _ <- runImportsT $ noisily $ noisily $ do modifyTestMode (const True) putDirs ["tmp"] putModule (S.ModuleName "Split")@@ -41,7 +41,7 @@ split2b = TestCase $ do _ <- rsync "testdata/split2" "tmp"- _ <- runCleanT $ noisily $ noisily $+ _ <- runImportsT $ noisily $ noisily $ do putDirs ["tmp"] putModule (S.ModuleName "Split") splitModuleDecls "tmp/Split.hs"@@ -57,7 +57,7 @@ TestLabel "Split4" $ TestCase $ do _ <- rsync "testdata/split4" "tmp" _ <- withCurrentDirectory "tmp" $- runCleanT $ noisily $ noisily $+ runImportsT $ noisily $ noisily $ modifyTestMode (const True) >> putModule (S.ModuleName "Split4") >> splitModuleDecls "Split4.hs"@@ -69,7 +69,7 @@ TestLabel "Split4b" $ TestCase $ do _ <- rsync "testdata/split4" "tmp" _ <- withCurrentDirectory "tmp" $- runCleanT $ noisily $ noisily $+ runImportsT $ noisily $ noisily $ modifyTestMode (const True) >> putModule (S.ModuleName "Split4") >> splitModule f "Split4.hs"@@ -86,7 +86,7 @@ TestLabel "Split4b" $ TestCase $ do _ <- rsync "testdata/split4" "tmp" _ <- withCurrentDirectory "tmp" $- runCleanT $ noisily $ noisily $+ runImportsT $ noisily $ noisily $ modifyTestMode (const True) >> putModule (S.ModuleName "Split4") >> splitModule f "Split4.hs"@@ -103,7 +103,7 @@ TestLabel "Split5" $ TestCase $ do _ <- rsync "testdata/split5" "tmp" _ <- withCurrentDirectory "tmp" $- runCleanT $ noisily $ noisily $+ runImportsT $ noisily $ noisily $ List.mapM_ (putModule . S.ModuleName) ["A", "B", "C", "D", "E"] >> modifyTestMode (const True) >> splitModuleDecls "B.hs"@@ -116,7 +116,7 @@ do _ <- rsync "testdata/debian" "tmp" _ <- withCurrentDirectory "tmp" $ findHsModules ["Debian", "Text", "Tmp"] >>= \ modules ->- runCleanT $ noisily $ noisily $+ runImportsT $ noisily $ noisily $ mapM putModule modules >> splitModule f "Debian/Repo/Monads/Apt.hs" result <- diff "testdata/split6-expected" "tmp"@@ -130,7 +130,7 @@ split7 = TestLabel "split7" $ TestCase $ do _ <- rsync "testdata/fold3b" "tmp"- _ <- withCurrentDirectory "tmp" $ runCleanT $+ _ <- withCurrentDirectory "tmp" $ runImportsT $ do putModule (S.ModuleName "Main") extraImport (S.ModuleName "Main.GetPasteById") (S.ModuleName "Main.Instances") extraImport (S.ModuleName "Main.GetRecentPastes") (S.ModuleName "Main.Instances")@@ -170,7 +170,7 @@ split7b = TestLabel "split7b" $ TestCase $ do _ <- rsync "testdata/fold3b" "tmp"- _ <- withCurrentDirectory "tmp" $ runCleanT $+ _ <- withCurrentDirectory "tmp" $ runImportsT $ do putModule (S.ModuleName "Main") extraImport (S.ModuleName "Main.GetPasteById") (S.ModuleName "Main.Instances") extraImport (S.ModuleName "Main.GetRecentPastes") (S.ModuleName "Main.Instances")
Tests/Symbols.hs view
@@ -24,7 +24,11 @@ test1 :: Test test1 = TestCase (assertEqual "DefaultDecl" " \ndefault (foo)" (prettyPrint (A.DefaultDecl def [A.TyVar def (A.Ident def "foo")] :: A.Decl SrcSpanInfo))) test2 :: Test-test2 = TestCase (assertEqual "PatBind" "pvar :: typ = unqualrhs" (prettyPrint (A.PatBind def (A.PVar def (A.Ident def "pvar")) (Just (A.TyVar def (A.Ident def "typ"))) (A.UnGuardedRhs def (A.Var def (A.UnQual def (A.Ident def "unqualrhs")))) Nothing :: A.Decl SrcSpanInfo)))+test2 = TestCase (assertEqual "PatBind" "pvar :: typ = unqualrhs" (prettyPrint (A.PatBind def (A.PVar def (A.Ident def "pvar"))+#if !MIN_VERSION_haskell_src_exts(1,16,0)+ (Just (A.TyVar def (A.Ident def "typ")))+#endif+ (A.UnGuardedRhs def (A.Var def (A.UnQual def (A.Ident def "unqualrhs")))) Nothing :: A.Decl SrcSpanInfo))) test3 :: Test test3 = TestCase (assertEqual "Pat" "pvar" (prettyPrint (A.PVar def (A.Ident def "pvar") :: A.Pat SrcSpanInfo))) test4 :: Test
changelog view
@@ -1,3 +1,9 @@+haskell-module-management (0.21) unstable; urgency=low++ * Rename runCleanT -> runImportsT++ -- David Fox <dsf@seereason.com> Sun, 01 May 2016 12:19:48 -0700+ haskell-module-management (0.20.3) unstable; urgency=low * Changes for haskell-src-exts-1.16
module-management.cabal view
@@ -1,5 +1,5 @@ Name: module-management-Version: 0.20.4+Version: 0.21 Synopsis: Clean up module imports, split and merge modules Description: Clean up module imports, split and merge modules. Homepage: https://github.com/seereason/module-management@@ -521,7 +521,7 @@ data-default, directory, filepath,- haskell-src-exts <= 1.17,+ haskell-src-exts <= 1.18, HUnit, lifted-base, monad-control,@@ -576,6 +576,6 @@ containers, filepath, HUnit,- haskell-src-exts <= 1.17,+ haskell-src-exts <= 1.18, module-management, process
scripts/CLI.hs view
@@ -18,7 +18,7 @@ import Distribution.Package (InstalledPackageId(..)) import GHC.Generics (Generic) import Language.Haskell.Exts.Syntax (Name(Ident, Symbol))-import Language.Haskell.Modules (cleanImports, CleanT, findHsModules, mergeModules, modifyDirs, ModuleName(..), MonadClean, noisily, putDirs, putModule, runCleanT, splitModuleDecls, splitModuleBy)+import Language.Haskell.Modules (cleanImports, CleanT, findHsModules, mergeModules, modifyDirs, ModuleName(..), MonadClean, noisily, putDirs, putModule, runImportsT, splitModuleDecls, splitModuleBy) import Language.Haskell.Modules.ModuVerse (getNames, getInfo, moduleName) import Language.Haskell.Modules.SourceDirs (getDirs) import Language.Haskell.Modules.Util.QIO (modifyVerbosity)@@ -116,7 +116,7 @@ execCmdM :: CmdM a -> IO (Maybe GenericPackageDescription)- execCmdM x = runCleanT+ execCmdM x = runImportsT $ flip execStateT pkgDesc' $ flip runReaderT conf $ runInputT (setComplete ((lift . lift) `fmap` compl conf) defaultSettings) x
scripts/CleanModules.hs view
@@ -4,7 +4,7 @@ import Options.Applicative import Control.Monad.Trans (MonadIO(liftIO))-import Language.Haskell.Modules (cleanImports, runCleanT)+import Language.Haskell.Modules (cleanImports, runImportsT) import System.Directory (getDirectoryContents) import System.Environment (getArgs) import System.FilePath (takeExtension)@@ -12,7 +12,7 @@ main = do args <- getArgs fs <- if null args then sourceFiles "." else return args- cs <- runCleanT $ mapM cleanImports' fs+ cs <- runImportsT $ mapM cleanImports' fs print cs cleanImports' fp = do (liftIO $ putStr "cleaning: " >> print fp) >> cleanImports fp
testdata/imports7-expected/CLI.hs view
@@ -5,13 +5,13 @@ import Control.Monad.Trans (MonadIO(liftIO)) import Data.List (intercalate, isPrefixOf) import Data.Set.Extra as Set (Set, toList)-import Language.Haskell.Modules (cleanImports, findHsModules, mergeModules, modifyDirs, ModuleName(..), MonadClean, noisily, putDirs, putModule, quietly, runCleanT, splitModuleDecls)+import Language.Haskell.Modules (cleanImports, findHsModules, mergeModules, modifyDirs, ModuleName(..), MonadClean, noisily, putDirs, putModule, quietly, runImportsT, splitModuleDecls) import Language.Haskell.Modules.ModuVerse (getNames) import Language.Haskell.Modules.SourceDirs (getDirs) import System.IO (hGetLine, hPutStr, hPutStrLn, stderr, stdin) main :: IO ()-main = runCleanT (noisily cli)+main = runImportsT (noisily cli) cli :: MonadClean m => m () cli = liftIO (hPutStr stderr " > " >> hGetLine stdin) >>= cmd . words
testdata/imports7/CLI.hs view
@@ -11,7 +11,7 @@ import System.IO (hGetLine, hPutStr, hPutStrLn, stderr, stdin) main :: IO ()-main = runCleanT (noisily cli)+main = runImportsT (noisily cli) cli :: MonadClean m => m () cli = liftIO (hPutStr stderr " > " >> hGetLine stdin) >>= cmd . words