packages feed

autoexporter 2.0.0.2 → 2.0.0.3

raw patch · 4 files changed

+21/−33 lines, 4 filesdep +Cabal-syntaxdep −Cabaldep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: Cabal-syntax

Dependencies removed: Cabal

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

LICENSE.markdown view
@@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Taylor Fausak+Copyright (c) 2023 Taylor Fausak  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
autoexporter.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2  name: autoexporter-version: 2.0.0.2+version: 2.0.0.3  synopsis: Automatically re-export modules. description: Autoexporter automatically re-exports modules.@@ -24,8 +24,8 @@  common library   build-depends:-    , base >= 4.13.0 && < 4.18-    , Cabal >= 3.0.1 && < 3.9+    , base >= 4.15.0 && < 4.18+    , Cabal-syntax >= 3.8.1 && < 3.9     , directory >= 1.3.6 && < 1.4     , filepath >= 1.4.2 && < 1.5   default-language: Haskell2010
source/executable/Main.hs view
@@ -1,6 +1,7 @@ module Main-  ( main-  ) where+  ( main,+  )+where  import qualified Autoexporter 
source/library/Autoexporter.hs view
@@ -6,8 +6,9 @@ -- For more information, please see the README on GitHub: -- <https://github.com/tfausak/autoexporter#readme>. module Autoexporter-  ( autoexporter-  ) where+  ( autoexporter,+  )+where  import qualified Control.Exception as Exception import qualified Data.List as List@@ -18,7 +19,6 @@ import qualified System.Environment as Environment import qualified System.FilePath as FilePath - autoexporter :: IO () autoexporter = do   -- Start by getting the command line arguments. We expect three positional@@ -52,7 +52,6 @@   let content = renderModule moduleName moduleNames   writeFile output content - -- | This type describes how to search for modules to export. A shallow search -- only considers files in one directory. A deep search considers all files in -- the directory tree.@@ -61,7 +60,6 @@   | DepthDeep   deriving (Eq, Show) - -- | This exception type is thrown when we don't know how to interpret the -- arguments passed to the program. newtype InvalidArguments@@ -70,7 +68,6 @@  instance Exception.Exception InvalidArguments - -- | This function attempts to convert an arbitrary file path into a valid -- Haskell module name. Any extensions are ignored. --@@ -88,7 +85,6 @@     . FilePath.splitDirectories     . FilePath.dropExtensions - -- | This exception type is thrown when we can't create a valid module name -- from the source file path. newtype InvalidModuleName@@ -97,7 +93,6 @@  instance Exception.Exception InvalidModuleName - -- | Lists all of the entries in the given directory. Note that unlike -- 'Directory.listDirectory' the results of calling this function will include -- the original directory name.@@ -106,55 +101,47 @@   DepthShallow -> listDirectoryShallow   DepthDeep -> listDirectoryDeep - listDirectoryShallow :: FilePath -> IO [FilePath] listDirectoryShallow directory = do   entries <- Directory.listDirectory directory   pure (fmap (FilePath.combine directory) entries) - listDirectoryDeep :: FilePath -> IO [FilePath] listDirectoryDeep directory = do   entries <- listDirectoryShallow directory-  let-    listEntry entry = do-      isDirectory <- Directory.doesDirectoryExist entry-      if isDirectory then listDirectoryDeep entry else pure [entry]+  let listEntry entry = do+        isDirectory <- Directory.doesDirectoryExist entry+        if isDirectory then listDirectoryDeep entry else pure [entry]   fmap concat (mapM listEntry entries) - -- | Given a list of file paths, returns a sorted list of module names from the -- entries that were Haskell files. getModuleNames :: [FilePath] -> [Cabal.ModuleName] getModuleNames =   List.sort . Maybe.mapMaybe toModuleName . filter isHaskellFile - -- | This predicate tells you if the given file path is a Haskell source file. isHaskellFile :: FilePath -> Bool isHaskellFile = flip elem haskellExtensions . FilePath.takeExtensions - -- | These are the extensions that we consider to be Haskell source files. haskellExtensions :: [String] haskellExtensions = [".hs", ".lhs"] - -- | Given a module name and a list of module names to re-export, renders a -- module with all the appropriate imports and exports. renderModule :: Cabal.ModuleName -> [Cabal.ModuleName] -> String-renderModule moduleName moduleNames = unlines-  [ "{-# OPTIONS_GHC -fno-warn-dodgy-exports -fno-warn-unused-imports #-}"-  , "module " <> Cabal.display moduleName <> " ("-  , List.intercalate "\n" (fmap renderExport moduleNames)-  , ") where"-  , List.intercalate "\n" (fmap renderImport moduleNames)-  ]-+renderModule moduleName moduleNames =+  unlines+    [ "{-# OPTIONS_GHC -fno-warn-dodgy-exports -fno-warn-unused-imports #-}",+      "module " <> Cabal.display moduleName <> " (",+      List.intercalate "\n" (fmap renderExport moduleNames),+      ") where",+      List.intercalate "\n" (fmap renderImport moduleNames)+    ]  renderExport :: Cabal.ModuleName -> String renderExport moduleName = "module " <> Cabal.display moduleName <> ","-  renderImport :: Cabal.ModuleName -> String renderImport moduleName = "import " <> Cabal.display moduleName