packages feed

filepather 0.6.0 → 0.6.1

raw patch · 5 files changed

+215/−10 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ System.FilePather.FilePather: contraFilePather :: forall (p1 :: Type -> Type -> Type) (f1 :: Type -> Type) a (p' :: Type -> Type -> Type) (f' :: Type -> Type) a' p2 f2. (Profunctor p2, Functor f2) => p2 (ContraKleisli p1 a f1 FilePath) (f2 (ContraKleisli p' a' f' FilePath)) -> p2 (FilePather p1 f1 a) (f2 (FilePather p' f' a'))
+ System.FilePather.FilePather: filePather :: forall p1 f1 a p' f' a' p2 f2. (Profunctor p2, Functor f2) => p2 (p1 FilePath (f1 a)) (f2 (p' FilePath (f' a'))) -> p2 (FilePather p1 f1 a) (f2 (FilePather p' f' a'))
+ System.FilePather.FilePather: proFilePather :: forall (p1 :: Type -> Type -> Type) (f1 :: Type -> Type) a (p' :: Type -> Type -> Type) (f' :: Type -> Type) a' p2 f2. (Profunctor p2, Functor f2) => p2 (ProKleisli p1 f1 FilePath a) (f2 (ProKleisli p' f' FilePath a')) -> p2 (FilePather p1 f1 a) (f2 (FilePather p' f' a'))

Files

changelog.md view
@@ -1,3 +1,9 @@+0.6.1++* Add doctests to `filePather`, `proFilePather`, and `contraFilePather` isomorphisms+* Add explicit `INLINE` pragmas to all function definitions+* Fix imports to use explicit import lists+ 0.6.0  * Replace `Kleisli (Identity . f)` with `mkKleisli'` throughout@@ -5,6 +11,9 @@ * Export all type aliases from all modules * Use `FilePatherIOA` for all IO function signatures * Use `FilePatherMaybeA` for `stripExtension` signature+* Add `filePather`, `proFilePather`, and `contraFilePather` lens isomorphisms+* Add `lens` dependency and `Control.Lens` integration+* Tighten `filepath` version bounds * Remove unused language extensions * Remove duplicate benchmark 
filepather.cabal view
@@ -1,6 +1,6 @@ cabal-version:        2.4 name:                 filepather-version:              0.6.0+version:              0.6.1 synopsis:             FilePath and Directory operations via Kleisli type aliases description:   Re-implementations of @System.FilePath@ and @System.Directory@ using
src/System/FilePather/FilePather.hs view
@@ -14,6 +14,11 @@     FilePatherIO,     FilePatherIOA, +    -- * Isomorphisms+    filePather,+    proFilePather,+    contraFilePather,+     -- * System.FilePath re-implementations     splitExtension,     takeExtension,@@ -135,16 +140,19 @@   ) where -import Data.Functor.Identity-import Data.Kleisli (Kleisli (..), mkKleisli')+import Control.Lens (Iso, _Wrapped)+import Data.Functor.Identity (Identity)+import Data.Kleisli (ContraKleisli, Kleisli (..), ProKleisli, mkKleisli', _Kleisli_ContraKleisli, _Kleisli_ProKleisli) import Data.Time.Clock (UTCTime) import qualified System.Directory as Dir import qualified System.FilePath as FP  -- $setup+-- >>> import Control.Lens (view, review) -- >>> import Data.Functor.Identity (Identity(..))--- >>> import Data.Kleisli (Kleisli(..))+-- >>> import Data.Kleisli (Kleisli(..), ProKleisli(..), ContraKleisli(..)) -- >>> import qualified System.Directory as Dir+-- >>> import qualified System.FilePath as FP -- >>> let run (Kleisli f) x = runIdentity (f x)  type FilePather p f a = Kleisli p FilePath f a@@ -163,6 +171,35 @@  type FilePatherIOA a = FilePatherIO (->) a +-- | An isomorphism between a 'FilePather' and its unwrapped representation.+--+-- >>> view filePather takeExtension "/tmp/foo.hs"+-- Identity ".hs"+--+-- >>> run (review filePather (Identity . FP.takeExtension)) "/tmp/foo.hs"+-- ".hs"+filePather :: Iso (FilePather p f a) (FilePather p' f' a') (p FilePath (f a)) (p' FilePath (f' a'))+filePather = _Wrapped+{-# INLINE filePather #-}++-- | An isomorphism between a 'FilePather' and a 'ProKleisli', reordering+-- type parameters to enable 'Category' and 'Arrow' instances.+--+-- >>> let ProKleisli f = view proFilePather takeExtension in runIdentity (f "/tmp/foo.hs")+-- ".hs"+proFilePather :: Iso (FilePather p f a) (FilePather p' f' a') (ProKleisli p f FilePath a) (ProKleisli p' f' FilePath a')+proFilePather = _Kleisli_ProKleisli+{-# INLINE proFilePather #-}++-- | An isomorphism between a 'FilePather' and a 'ContraKleisli', reordering+-- type parameters to enable 'Contravariant' instances.+--+-- >>> let ContraKleisli f = view contraFilePather takeExtension in runIdentity (f "/tmp/foo.hs")+-- ".hs"+contraFilePather :: Iso (FilePather p f a) (FilePather p' f' a') (ContraKleisli p a f FilePath) (ContraKleisli p' a' f' FilePath)+contraFilePather = _Kleisli_ContraKleisli+{-# INLINE contraFilePather #-}+ ------------------------------------------------------------ -- System.FilePath ------------------------------------------------------------@@ -179,6 +216,7 @@ -- ("/tmp/foo.tar",".gz") splitExtension :: FilePatherA' (String, String) splitExtension = mkKleisli' FP.splitExtension+{-# INLINE splitExtension #-}  -- | Get the extension of a file path. --@@ -190,9 +228,9 @@ -- -- >>> run takeExtension "/tmp/foo.tar.gz" -- ".gz"--- takeExtension :: FilePatherA' String takeExtension = mkKleisli' FP.takeExtension+{-# INLINE takeExtension #-}  -- | Replace the extension of a file path. --@@ -206,6 +244,7 @@ -- "/tmp/foo" replaceExtension :: String -> FilePatherA' FilePath replaceExtension s = mkKleisli' (`FP.replaceExtension` s)+{-# INLINE replaceExtension #-}  -- | Remove the extension from a file path. --@@ -219,6 +258,7 @@ -- "/tmp/foo.tar" dropExtension :: FilePatherA' FilePath dropExtension = mkKleisli' FP.dropExtension+{-# INLINE dropExtension #-}  -- | Add an extension to a file path. --@@ -232,6 +272,7 @@ -- "/tmp/foo.hs" addExtension :: String -> FilePatherA' FilePath addExtension s = mkKleisli' (`FP.addExtension` s)+{-# INLINE addExtension #-}  -- | Does the file path have an extension? --@@ -240,9 +281,9 @@ -- -- >>> run hasExtension "/tmp/foo" -- False--- hasExtension :: FilePatherA' Bool hasExtension = mkKleisli' FP.hasExtension+{-# INLINE hasExtension #-}  -- | Split all extensions from a file path. --@@ -253,6 +294,7 @@ -- ("/tmp/foo","") splitExtensions :: FilePatherA' (FilePath, String) splitExtensions = mkKleisli' FP.splitExtensions+{-# INLINE splitExtensions #-}  -- | Get all extensions from a file path. --@@ -266,6 +308,7 @@ -- ".a.b.c" takeExtensions :: FilePatherA' String takeExtensions = mkKleisli' FP.takeExtensions+{-# INLINE takeExtensions #-}  -- | Drop all extensions from a file path. --@@ -276,6 +319,7 @@ -- "/tmp/foo" dropExtensions :: FilePatherA' FilePath dropExtensions = mkKleisli' FP.dropExtensions+{-# INLINE dropExtensions #-}  -- | Replace all extensions of a file path. --@@ -286,6 +330,7 @@ -- "/tmp/foo.a.b" replaceExtensions :: String -> FilePatherA' FilePath replaceExtensions s = mkKleisli' (`FP.replaceExtensions` s)+{-# INLINE replaceExtensions #-}  -- | Is the given string an extension of the file path? --@@ -302,6 +347,7 @@ -- True isExtensionOf :: String -> FilePatherA' Bool isExtensionOf s = mkKleisli' (FP.isExtensionOf s)+{-# INLINE isExtensionOf #-}  -- | Strip an extension from a file path, returning 'Nothing' if the -- extension does not match.@@ -319,6 +365,7 @@ -- Just "/tmp/foo" stripExtension :: String -> FilePatherMaybeA FilePath stripExtension s = Kleisli (FP.stripExtension s)+{-# INLINE stripExtension #-}  -- | Split a file path into directory and file components. --@@ -332,6 +379,7 @@ -- ("./","foo.hs") splitFileName :: FilePatherA' (String, String) splitFileName = mkKleisli' FP.splitFileName+{-# INLINE splitFileName #-}  -- | Get the file name component of a file path. --@@ -345,6 +393,7 @@ -- "foo.hs" takeFileName :: FilePatherA' FilePath takeFileName = mkKleisli' FP.takeFileName+{-# INLINE takeFileName #-}  -- | Replace the file name component of a file path. --@@ -355,6 +404,7 @@ -- "/tmp/baz" replaceFileName :: String -> FilePatherA' FilePath replaceFileName s = mkKleisli' (`FP.replaceFileName` s)+{-# INLINE replaceFileName #-}  -- | Drop the file name component of a file path. --@@ -365,6 +415,7 @@ -- "./" dropFileName :: FilePatherA' FilePath dropFileName = mkKleisli' FP.dropFileName+{-# INLINE dropFileName #-}  -- | Get the base name (file name without extension) of a file path. --@@ -378,6 +429,7 @@ -- "" takeBaseName :: FilePatherA' String takeBaseName = mkKleisli' FP.takeBaseName+{-# INLINE takeBaseName #-}  -- | Replace the base name of a file path. --@@ -388,6 +440,7 @@ -- "/tmp/quux.gz" replaceBaseName :: String -> FilePatherA' FilePath replaceBaseName s = mkKleisli' (`FP.replaceBaseName` s)+{-# INLINE replaceBaseName #-}  -- | Get the directory component of a file path. --@@ -404,6 +457,7 @@ -- "/tmp/src" takeDirectory :: FilePatherA' FilePath takeDirectory = mkKleisli' FP.takeDirectory+{-# INLINE takeDirectory #-}  -- | Replace the directory component of a file path. --@@ -414,6 +468,7 @@ -- "src/foo.hs" replaceDirectory :: String -> FilePatherA' FilePath replaceDirectory s = mkKleisli' (`FP.replaceDirectory` s)+{-# INLINE replaceDirectory #-}  -- | Combine a directory path with a file path. --@@ -427,6 +482,7 @@ -- "src/Data/Foo.hs" combine :: FilePath -> FilePatherA' FilePath combine s = mkKleisli' (FP.combine s)+{-# INLINE combine #-}  -- | Split a file path into its path components. --@@ -440,6 +496,7 @@ -- ["foo.hs"] splitPath :: FilePatherA' [FilePath] splitPath = mkKleisli' FP.splitPath+{-# INLINE splitPath #-}  -- | Split a file path into its directory components. --@@ -453,6 +510,7 @@ -- ["/"] splitDirectories :: FilePatherA' [FilePath] splitDirectories = mkKleisli' FP.splitDirectories+{-# INLINE splitDirectories #-}  -- | Split a file path into drive and remainder. --@@ -463,6 +521,7 @@ -- ("","tmp/foo") splitDrive :: FilePatherA' (FilePath, FilePath) splitDrive = mkKleisli' FP.splitDrive+{-# INLINE splitDrive #-}  -- | Join a drive and the rest of a path. --@@ -473,6 +532,7 @@ -- "tmp/foo" joinDrive :: FilePath -> FilePatherA' FilePath joinDrive s = mkKleisli' (FP.joinDrive s)+{-# INLINE joinDrive #-}  -- | Get the drive of a file path. --@@ -483,6 +543,7 @@ -- "" takeDrive :: FilePatherA' FilePath takeDrive = mkKleisli' FP.takeDrive+{-# INLINE takeDrive #-}  -- | Does the file path have a drive? --@@ -493,6 +554,7 @@ -- False hasDrive :: FilePatherA' Bool hasDrive = mkKleisli' FP.hasDrive+{-# INLINE hasDrive #-}  -- | Drop the drive from a file path. --@@ -503,6 +565,7 @@ -- "tmp/foo" dropDrive :: FilePatherA' FilePath dropDrive = mkKleisli' FP.dropDrive+{-# INLINE dropDrive #-}  -- | Is the file path a drive? --@@ -513,6 +576,7 @@ -- False isDrive :: FilePatherA' Bool isDrive = mkKleisli' FP.isDrive+{-# INLINE isDrive #-}  -- | Does the file path have a trailing path separator? --@@ -523,6 +587,7 @@ -- False hasTrailingPathSeparator :: FilePatherA' Bool hasTrailingPathSeparator = mkKleisli' FP.hasTrailingPathSeparator+{-# INLINE hasTrailingPathSeparator #-}  -- | Add a trailing path separator if one is not present. --@@ -533,6 +598,7 @@ -- "/tmp/" addTrailingPathSeparator :: FilePatherA' FilePath addTrailingPathSeparator = mkKleisli' FP.addTrailingPathSeparator+{-# INLINE addTrailingPathSeparator #-}  -- | Drop the trailing path separator if present. --@@ -546,6 +612,7 @@ -- "/" dropTrailingPathSeparator :: FilePatherA' FilePath dropTrailingPathSeparator = mkKleisli' FP.dropTrailingPathSeparator+{-# INLINE dropTrailingPathSeparator #-}  -- | Normalise a file path. --@@ -559,6 +626,7 @@ -- "/tmp/foo/" normalise :: FilePatherA' FilePath normalise = mkKleisli' FP.normalise+{-# INLINE normalise #-}  -- | Make a file path relative to a given directory. --@@ -572,6 +640,7 @@ -- "/tmp/foo.hs" makeRelative :: FilePath -> FilePatherA' FilePath makeRelative s = mkKleisli' (FP.makeRelative s)+{-# INLINE makeRelative #-}  -- | Are two file paths equal (accounting for normalisation)? --@@ -585,6 +654,7 @@ -- True equalFilePath :: FilePath -> FilePatherA' Bool equalFilePath s = mkKleisli' (FP.equalFilePath s)+{-# INLINE equalFilePath #-}  -- | Is the file path relative? --@@ -598,6 +668,7 @@ -- True isRelative :: FilePatherA' Bool isRelative = mkKleisli' FP.isRelative+{-# INLINE isRelative #-}  -- | Is the file path absolute? --@@ -611,6 +682,7 @@ -- True isAbsolute :: FilePatherA' Bool isAbsolute = mkKleisli' FP.isAbsolute+{-# INLINE isAbsolute #-}  -- | Is the file path valid? --@@ -621,6 +693,7 @@ -- False isValid :: FilePatherA' Bool isValid = mkKleisli' FP.isValid+{-# INLINE isValid #-}  -- | Make a file path valid by replacing invalid characters. --@@ -631,6 +704,7 @@ -- "/tmp/foo" makeValid :: FilePatherA' FilePath makeValid = mkKleisli' FP.makeValid+{-# INLINE makeValid #-}  -- | Combine two file paths with a path separator. Synonym for 'combine'. --@@ -641,6 +715,7 @@ -- "src/Data/Foo.hs" (</>) :: FilePath -> FilePatherA' FilePath (</>) = combine+{-# INLINE (</>) #-}  -- | Add an extension to a file path. Synonym for 'addExtension'. --@@ -651,6 +726,7 @@ -- "/tmp/foo.tar.gz" (<.>) :: String -> FilePatherA' FilePath (<.>) = addExtension+{-# INLINE (<.>) #-}  -- | Replace the extension of a file path. Synonym for 'replaceExtension'. --@@ -661,6 +737,7 @@ -- "/tmp/foo.txt" (-<.>) :: String -> FilePatherA' FilePath (-<.>) = replaceExtension+{-# INLINE (-<.>) #-}  ------------------------------------------------------------ -- System.Directory@@ -671,12 +748,14 @@ -- >>> let Kleisli f = createDirectory in f "/tmp/filepather_test_create_938271" >> Dir.removeDirectory "/tmp/filepather_test_create_938271" createDirectory :: FilePatherIOA () createDirectory = Kleisli Dir.createDirectory+{-# INLINE createDirectory #-}  -- | Create a directory and any missing parent directories. -- -- >>> let Kleisli f = createDirectoryIfMissing True in f "/tmp/filepather_test_mkdirs_938271/a/b" >> Dir.removeDirectoryRecursive "/tmp/filepather_test_mkdirs_938271" createDirectoryIfMissing :: Bool -> FilePatherIOA () createDirectoryIfMissing b = Kleisli (Dir.createDirectoryIfMissing b)+{-# INLINE createDirectoryIfMissing #-}  -- | Remove an existing directory. --@@ -684,6 +763,7 @@ -- >>> let Kleisli f = removeDirectory in f "/tmp/filepather_test_rmdir_938271" removeDirectory :: FilePatherIOA () removeDirectory = Kleisli Dir.removeDirectory+{-# INLINE removeDirectory #-}  -- | Remove a directory and all its contents recursively. --@@ -691,6 +771,7 @@ -- >>> let Kleisli f = removeDirectoryRecursive in f "/tmp/filepather_test_rmr_938271" removeDirectoryRecursive :: FilePatherIOA () removeDirectoryRecursive = Kleisli Dir.removeDirectoryRecursive+{-# INLINE removeDirectoryRecursive #-}  -- | Remove a path forcibly (file or directory, recursively). --@@ -698,6 +779,7 @@ -- >>> let Kleisli f = removePathForcibly in f "/tmp/filepather_test_rmf_938271" removePathForcibly :: FilePatherIOA () removePathForcibly = Kleisli Dir.removePathForcibly+{-# INLINE removePathForcibly #-}  -- | Rename a directory to a new path. --@@ -706,6 +788,7 @@ -- >>> Dir.removeDirectory "/tmp/filepather_test_rend2_938271" renameDirectory :: FilePath -> FilePatherIOA () renameDirectory dest = Kleisli (`Dir.renameDirectory` dest)+{-# INLINE renameDirectory #-}  -- | List the contents of a directory (excluding @.@ and @..@). --@@ -713,6 +796,7 @@ -- True listDirectory :: FilePatherIOA [FilePath] listDirectory = Kleisli Dir.listDirectory+{-# INLINE listDirectory #-}  -- | Get all entries in a directory (including @.@ and @..@). --@@ -720,6 +804,7 @@ -- True getDirectoryContents :: FilePatherIOA [FilePath] getDirectoryContents = Kleisli Dir.getDirectoryContents+{-# INLINE getDirectoryContents #-}  -- | Set the current working directory. --@@ -727,12 +812,14 @@ -- True setCurrentDirectory :: FilePatherIOA () setCurrentDirectory = Kleisli Dir.setCurrentDirectory+{-# INLINE setCurrentDirectory #-}  -- | Run an IO action with the given directory as the working directory. -- -- >>> let Kleisli f = withCurrentDirectory (pure ()) in f "/tmp" withCurrentDirectory :: IO a -> FilePatherIOA a withCurrentDirectory act = Kleisli (`Dir.withCurrentDirectory` act)+{-# INLINE withCurrentDirectory #-}  -- | Get an XDG directory for the given application. --@@ -740,6 +827,7 @@ -- True getXdgDirectory :: Dir.XdgDirectory -> FilePatherIOA FilePath getXdgDirectory xdg = Kleisli (Dir.getXdgDirectory xdg)+{-# INLINE getXdgDirectory #-}  -- | Get the application user data directory. --@@ -747,6 +835,7 @@ -- True getAppUserDataDirectory :: FilePatherIOA FilePath getAppUserDataDirectory = Kleisli Dir.getAppUserDataDirectory+{-# INLINE getAppUserDataDirectory #-}  -- | Remove a file. --@@ -754,6 +843,7 @@ -- >>> let Kleisli f = removeFile in f "/tmp/filepather_test_rm_938271" removeFile :: FilePatherIOA () removeFile = Kleisli Dir.removeFile+{-# INLINE removeFile #-}  -- | Rename a file to a new path. --@@ -762,6 +852,7 @@ -- >>> Dir.removeFile "/tmp/filepather_test_renf2_938271" renameFile :: FilePath -> FilePatherIOA () renameFile dest = Kleisli (`Dir.renameFile` dest)+{-# INLINE renameFile #-}  -- | Rename a file or directory to a new path. --@@ -770,6 +861,7 @@ -- >>> Dir.removeFile "/tmp/filepather_test_renp2_938271" renamePath :: FilePath -> FilePatherIOA () renamePath dest = Kleisli (`Dir.renamePath` dest)+{-# INLINE renamePath #-}  -- | Copy a file to a new path. --@@ -778,6 +870,7 @@ -- >>> Dir.removeFile "/tmp/filepather_test_cp_938271" >> Dir.removeFile "/tmp/filepather_test_cp2_938271" copyFile :: FilePath -> FilePatherIOA () copyFile dest = Kleisli (`Dir.copyFile` dest)+{-# INLINE copyFile #-}  -- | Copy a file preserving metadata. --@@ -786,6 +879,7 @@ -- >>> Dir.removeFile "/tmp/filepather_test_cpm_938271" >> Dir.removeFile "/tmp/filepather_test_cpm2_938271" copyFileWithMetadata :: FilePath -> FilePatherIOA () copyFileWithMetadata dest = Kleisli (`Dir.copyFileWithMetadata` dest)+{-# INLINE copyFileWithMetadata #-}  -- | Canonicalize a file path (resolve symlinks and relative components). --@@ -796,6 +890,7 @@ -- True canonicalizePath :: FilePatherIOA FilePath canonicalizePath = Kleisli Dir.canonicalizePath+{-# INLINE canonicalizePath #-}  -- | Make a file path absolute. --@@ -806,6 +901,7 @@ -- True makeAbsolute :: FilePatherIOA FilePath makeAbsolute = Kleisli Dir.makeAbsolute+{-# INLINE makeAbsolute #-}  -- | Make a file path relative to the current directory. --@@ -813,6 +909,7 @@ -- True makeRelativeToCurrentDirectory :: FilePatherIOA FilePath makeRelativeToCurrentDirectory = Kleisli Dir.makeRelativeToCurrentDirectory+{-# INLINE makeRelativeToCurrentDirectory #-}  -- | Does the path exist (file or directory)? --@@ -823,6 +920,7 @@ -- False doesPathExist :: FilePatherIOA Bool doesPathExist = Kleisli Dir.doesPathExist+{-# INLINE doesPathExist #-}  -- | Does the file exist? --@@ -830,6 +928,7 @@ -- False doesFileExist :: FilePatherIOA Bool doesFileExist = Kleisli Dir.doesFileExist+{-# INLINE doesFileExist #-}  -- | Does the directory exist? --@@ -840,6 +939,7 @@ -- False doesDirectoryExist :: FilePatherIOA Bool doesDirectoryExist = Kleisli Dir.doesDirectoryExist+{-# INLINE doesDirectoryExist #-}  -- | Create a file symbolic link. The first argument is the link target. --@@ -848,6 +948,7 @@ -- True createFileLink :: FilePath -> FilePatherIOA () createFileLink target = Kleisli (Dir.createFileLink target)+{-# INLINE createFileLink #-}  -- | Create a directory symbolic link. The first argument is the link target. --@@ -856,6 +957,7 @@ -- True createDirectoryLink :: FilePath -> FilePatherIOA () createDirectoryLink target = Kleisli (Dir.createDirectoryLink target)+{-# INLINE createDirectoryLink #-}  -- | Remove a directory symbolic link. --@@ -864,6 +966,7 @@ -- >>> let Kleisli f = removeDirectoryLink in f "/tmp/filepather_test_rmdl_938271" removeDirectoryLink :: FilePatherIOA () removeDirectoryLink = Kleisli Dir.removeDirectoryLink+{-# INLINE removeDirectoryLink #-}  -- | Get the target of a symbolic link. --@@ -873,6 +976,7 @@ -- "/dev/null" getSymbolicLinkTarget :: FilePatherIOA FilePath getSymbolicLinkTarget = Kleisli Dir.getSymbolicLinkTarget+{-# INLINE getSymbolicLinkTarget #-}  -- | Is the path a symbolic link? --@@ -880,6 +984,7 @@ -- False isSymbolicLink :: FilePatherIOA Bool isSymbolicLink = Kleisli Dir.pathIsSymbolicLink+{-# INLINE isSymbolicLink #-}  -- | Is the path a symbolic link? (Same as 'isSymbolicLink'.) --@@ -887,6 +992,7 @@ -- False pathIsSymbolicLink :: FilePatherIOA Bool pathIsSymbolicLink = Kleisli Dir.pathIsSymbolicLink+{-# INLINE pathIsSymbolicLink #-}  -- | Get the permissions of a file or directory. --@@ -894,6 +1000,7 @@ -- True getPermissions :: FilePatherIOA Dir.Permissions getPermissions = Kleisli Dir.getPermissions+{-# INLINE getPermissions #-}  -- | Set the permissions of a file or directory. --@@ -902,6 +1009,7 @@ -- True setPermissions :: Dir.Permissions -> FilePatherIOA () setPermissions p = Kleisli (`Dir.setPermissions` p)+{-# INLINE setPermissions #-}  -- | Copy the permissions from one path to another. --@@ -910,6 +1018,7 @@ -- >>> let Kleisli f = copyPermissions "/tmp/filepather_test_cpp_src_938271" in f "/tmp/filepather_test_cpp_938271" >> Dir.removeFile "/tmp/filepather_test_cpp_938271" >> Dir.removeFile "/tmp/filepather_test_cpp_src_938271" copyPermissions :: FilePath -> FilePatherIOA () copyPermissions dest = Kleisli (`Dir.copyPermissions` dest)+{-# INLINE copyPermissions #-}  -- | Get the access time of a file or directory. --@@ -917,6 +1026,7 @@ -- True getAccessTime :: FilePatherIOA UTCTime getAccessTime = Kleisli Dir.getAccessTime+{-# INLINE getAccessTime #-}  -- | Get the modification time of a file or directory. --@@ -924,6 +1034,7 @@ -- True getModificationTime :: FilePatherIOA UTCTime getModificationTime = Kleisli Dir.getModificationTime+{-# INLINE getModificationTime #-}  -- | Set the access time of a file or directory. --@@ -932,6 +1043,7 @@ -- True setAccessTime :: UTCTime -> FilePatherIOA () setAccessTime t = Kleisli (`Dir.setAccessTime` t)+{-# INLINE setAccessTime #-}  -- | Set the modification time of a file or directory. --@@ -940,6 +1052,7 @@ -- True setModificationTime :: UTCTime -> FilePatherIOA () setModificationTime t = Kleisli (`Dir.setModificationTime` t)+{-# INLINE setModificationTime #-}  -- | Get the size of a file in bytes. --@@ -948,3 +1061,4 @@ -- 5 getFileSize :: FilePatherIOA Integer getFileSize = Kleisli Dir.getFileSize+{-# INLINE getFileSize #-}
src/System/FilePather/FilePather/Posix.hs view
@@ -73,7 +73,7 @@   ) where -import Data.Functor.Identity+import Data.Functor.Identity (Identity) import Data.Kleisli (Kleisli (..), mkKleisli') import qualified System.FilePath.Posix as FP @@ -110,6 +110,7 @@ -- ("/tmp/foo.tar",".gz") splitExtension :: FilePatherA' (String, String) splitExtension = mkKleisli' FP.splitExtension+{-# INLINE splitExtension #-}  -- | Get the extension of a file path (Posix). --@@ -118,9 +119,9 @@ -- -- >>> run takeExtension "/tmp/foo" -- ""--- takeExtension :: FilePatherA' String takeExtension = mkKleisli' FP.takeExtension+{-# INLINE takeExtension #-}  -- | Replace the extension of a file path (Posix). --@@ -134,6 +135,7 @@ -- "/tmp/foo" replaceExtension :: String -> FilePatherA' FilePath replaceExtension s = mkKleisli' (`FP.replaceExtension` s)+{-# INLINE replaceExtension #-}  -- | Remove the extension from a file path (Posix). --@@ -144,6 +146,7 @@ -- "/tmp/foo" dropExtension :: FilePatherA' FilePath dropExtension = mkKleisli' FP.dropExtension+{-# INLINE dropExtension #-}  -- | Add an extension to a file path (Posix). --@@ -157,6 +160,7 @@ -- "/tmp/foo.hs" addExtension :: String -> FilePatherA' FilePath addExtension s = mkKleisli' (`FP.addExtension` s)+{-# INLINE addExtension #-}  -- | Does the file path have an extension? (Posix) --@@ -165,9 +169,9 @@ -- -- >>> run hasExtension "/tmp/foo" -- False--- hasExtension :: FilePatherA' Bool hasExtension = mkKleisli' FP.hasExtension+{-# INLINE hasExtension #-}  -- | Split all extensions from a file path (Posix). --@@ -178,6 +182,7 @@ -- ("/tmp/foo","") splitExtensions :: FilePatherA' (FilePath, String) splitExtensions = mkKleisli' FP.splitExtensions+{-# INLINE splitExtensions #-}  -- | Get all extensions from a file path (Posix). --@@ -188,6 +193,7 @@ -- "" takeExtensions :: FilePatherA' String takeExtensions = mkKleisli' FP.takeExtensions+{-# INLINE takeExtensions #-}  -- | Drop all extensions from a file path (Posix). --@@ -198,6 +204,7 @@ -- "/tmp/foo" dropExtensions :: FilePatherA' FilePath dropExtensions = mkKleisli' FP.dropExtensions+{-# INLINE dropExtensions #-}  -- | Replace all extensions of a file path (Posix). --@@ -208,6 +215,7 @@ -- "/tmp/foo.a.b" replaceExtensions :: String -> FilePatherA' FilePath replaceExtensions s = mkKleisli' (`FP.replaceExtensions` s)+{-# INLINE replaceExtensions #-}  -- | Is the given string an extension of the file path? (Posix) --@@ -221,6 +229,7 @@ -- True isExtensionOf :: String -> FilePatherA' Bool isExtensionOf s = mkKleisli' (FP.isExtensionOf s)+{-# INLINE isExtensionOf #-}  -- | Strip an extension from a file path (Posix), returning 'Nothing' if it -- does not match.@@ -235,6 +244,7 @@ -- Just "/tmp/foo.tar" stripExtension :: String -> FilePatherMaybeA FilePath stripExtension s = Kleisli (FP.stripExtension s)+{-# INLINE stripExtension #-}  -- | Split a file path into directory and file components (Posix). --@@ -248,6 +258,7 @@ -- ("./","foo.hs") splitFileName :: FilePatherA' (String, String) splitFileName = mkKleisli' FP.splitFileName+{-# INLINE splitFileName #-}  -- | Get the file name component of a file path (Posix). --@@ -261,6 +272,7 @@ -- "foo.hs" takeFileName :: FilePatherA' FilePath takeFileName = mkKleisli' FP.takeFileName+{-# INLINE takeFileName #-}  -- | Replace the file name component of a file path (Posix). --@@ -271,6 +283,7 @@ -- "/tmp/baz" replaceFileName :: String -> FilePatherA' FilePath replaceFileName s = mkKleisli' (`FP.replaceFileName` s)+{-# INLINE replaceFileName #-}  -- | Drop the file name component of a file path (Posix). --@@ -281,6 +294,7 @@ -- "./" dropFileName :: FilePatherA' FilePath dropFileName = mkKleisli' FP.dropFileName+{-# INLINE dropFileName #-}  -- | Get the base name (file name without extension) of a file path (Posix). --@@ -294,6 +308,7 @@ -- "" takeBaseName :: FilePatherA' String takeBaseName = mkKleisli' FP.takeBaseName+{-# INLINE takeBaseName #-}  -- | Replace the base name of a file path (Posix). --@@ -304,6 +319,7 @@ -- "/tmp/quux.gz" replaceBaseName :: String -> FilePatherA' FilePath replaceBaseName s = mkKleisli' (`FP.replaceBaseName` s)+{-# INLINE replaceBaseName #-}  -- | Get the directory component of a file path (Posix). --@@ -317,6 +333,7 @@ -- "." takeDirectory :: FilePatherA' FilePath takeDirectory = mkKleisli' FP.takeDirectory+{-# INLINE takeDirectory #-}  -- | Replace the directory component of a file path (Posix). --@@ -327,6 +344,7 @@ -- "src/foo.hs" replaceDirectory :: String -> FilePatherA' FilePath replaceDirectory s = mkKleisli' (`FP.replaceDirectory` s)+{-# INLINE replaceDirectory #-}  -- | Combine a directory path with a file path (Posix). --@@ -340,6 +358,7 @@ -- "src/Data/Foo.hs" combine :: FilePath -> FilePatherA' FilePath combine s = mkKleisli' (FP.combine s)+{-# INLINE combine #-}  -- | Split a file path into its path components (Posix). --@@ -350,6 +369,7 @@ -- ["src/","foo.hs"] splitPath :: FilePatherA' [FilePath] splitPath = mkKleisli' FP.splitPath+{-# INLINE splitPath #-}  -- | Split a file path into its directory components (Posix). --@@ -360,6 +380,7 @@ -- ["/"] splitDirectories :: FilePatherA' [FilePath] splitDirectories = mkKleisli' FP.splitDirectories+{-# INLINE splitDirectories #-}  -- | Split a file path into drive and remainder (Posix). --@@ -370,6 +391,7 @@ -- ("","tmp/foo") splitDrive :: FilePatherA' (FilePath, FilePath) splitDrive = mkKleisli' FP.splitDrive+{-# INLINE splitDrive #-}  -- | Join a drive and the rest of a path (Posix). --@@ -380,6 +402,7 @@ -- "tmp/foo" joinDrive :: FilePath -> FilePatherA' FilePath joinDrive s = mkKleisli' (FP.joinDrive s)+{-# INLINE joinDrive #-}  -- | Get the drive of a file path (Posix). --@@ -390,6 +413,7 @@ -- "" takeDrive :: FilePatherA' FilePath takeDrive = mkKleisli' FP.takeDrive+{-# INLINE takeDrive #-}  -- | Does the file path have a drive? (Posix) --@@ -400,6 +424,7 @@ -- False hasDrive :: FilePatherA' Bool hasDrive = mkKleisli' FP.hasDrive+{-# INLINE hasDrive #-}  -- | Drop the drive from a file path (Posix). --@@ -410,6 +435,7 @@ -- "tmp/foo" dropDrive :: FilePatherA' FilePath dropDrive = mkKleisli' FP.dropDrive+{-# INLINE dropDrive #-}  -- | Is the file path a drive? (Posix) --@@ -420,6 +446,7 @@ -- False isDrive :: FilePatherA' Bool isDrive = mkKleisli' FP.isDrive+{-# INLINE isDrive #-}  -- | Does the file path have a trailing path separator? (Posix) --@@ -430,6 +457,7 @@ -- False hasTrailingPathSeparator :: FilePatherA' Bool hasTrailingPathSeparator = mkKleisli' FP.hasTrailingPathSeparator+{-# INLINE hasTrailingPathSeparator #-}  -- | Add a trailing path separator if one is not present (Posix). --@@ -440,6 +468,7 @@ -- "/tmp/" addTrailingPathSeparator :: FilePatherA' FilePath addTrailingPathSeparator = mkKleisli' FP.addTrailingPathSeparator+{-# INLINE addTrailingPathSeparator #-}  -- | Drop the trailing path separator if present (Posix). --@@ -453,6 +482,7 @@ -- "/" dropTrailingPathSeparator :: FilePatherA' FilePath dropTrailingPathSeparator = mkKleisli' FP.dropTrailingPathSeparator+{-# INLINE dropTrailingPathSeparator #-}  -- | Normalise a file path (Posix). --@@ -463,6 +493,7 @@ -- "/tmp/foo" normalise :: FilePatherA' FilePath normalise = mkKleisli' FP.normalise+{-# INLINE normalise #-}  -- | Make a file path relative to a given directory (Posix). --@@ -476,6 +507,7 @@ -- "/tmp/foo.hs" makeRelative :: FilePath -> FilePatherA' FilePath makeRelative s = mkKleisli' (FP.makeRelative s)+{-# INLINE makeRelative #-}  -- | Are two file paths equal? (Posix, accounting for normalisation) --@@ -489,6 +521,7 @@ -- True equalFilePath :: FilePath -> FilePatherA' Bool equalFilePath s = mkKleisli' (FP.equalFilePath s)+{-# INLINE equalFilePath #-}  -- | Is the file path relative? (Posix) --@@ -499,6 +532,7 @@ -- False isRelative :: FilePatherA' Bool isRelative = mkKleisli' FP.isRelative+{-# INLINE isRelative #-}  -- | Is the file path absolute? (Posix) --@@ -509,6 +543,7 @@ -- False isAbsolute :: FilePatherA' Bool isAbsolute = mkKleisli' FP.isAbsolute+{-# INLINE isAbsolute #-}  -- | Is the file path valid? (Posix) --@@ -519,6 +554,7 @@ -- False isValid :: FilePatherA' Bool isValid = mkKleisli' FP.isValid+{-# INLINE isValid #-}  -- | Make a file path valid (Posix). --@@ -529,6 +565,7 @@ -- "/tmp/foo" makeValid :: FilePatherA' FilePath makeValid = mkKleisli' FP.makeValid+{-# INLINE makeValid #-}  -- | Combine two file paths (Posix). Synonym for 'combine'. --@@ -539,6 +576,7 @@ -- "src/Data/Foo.hs" (</>) :: FilePath -> FilePatherA' FilePath (</>) = combine+{-# INLINE (</>) #-}  -- | Add an extension (Posix). Synonym for 'addExtension'. --@@ -549,6 +587,7 @@ -- "/tmp/foo.tar.gz" (<.>) :: String -> FilePatherA' FilePath (<.>) = addExtension+{-# INLINE (<.>) #-}  -- | Replace the extension (Posix). Synonym for 'replaceExtension'. --@@ -559,3 +598,4 @@ -- "/tmp/foo.txt" (-<.>) :: String -> FilePatherA' FilePath (-<.>) = replaceExtension+{-# INLINE (-<.>) #-}
src/System/FilePather/FilePather/Windows.hs view
@@ -73,7 +73,7 @@   ) where -import Data.Functor.Identity+import Data.Functor.Identity (Identity) import Data.Kleisli (Kleisli (..), mkKleisli') import qualified System.FilePath.Windows as FP @@ -110,6 +110,7 @@ -- ("C:\\tmp\\foo.tar",".gz") splitExtension :: FilePatherA' (String, String) splitExtension = mkKleisli' FP.splitExtension+{-# INLINE splitExtension #-}  -- | Get the extension of a file path (Windows). --@@ -123,6 +124,7 @@ -- ".gz" takeExtension :: FilePatherA' String takeExtension = mkKleisli' FP.takeExtension+{-# INLINE takeExtension #-}  -- | Replace the extension of a file path (Windows). --@@ -136,6 +138,7 @@ -- "C:\\tmp\\foo" replaceExtension :: String -> FilePatherA' FilePath replaceExtension s = mkKleisli' (`FP.replaceExtension` s)+{-# INLINE replaceExtension #-}  -- | Remove the extension from a file path (Windows). --@@ -146,6 +149,7 @@ -- "C:\\tmp\\foo" dropExtension :: FilePatherA' FilePath dropExtension = mkKleisli' FP.dropExtension+{-# INLINE dropExtension #-}  -- | Add an extension to a file path (Windows). --@@ -159,6 +163,7 @@ -- "C:\\tmp\\foo.hs" addExtension :: String -> FilePatherA' FilePath addExtension s = mkKleisli' (`FP.addExtension` s)+{-# INLINE addExtension #-}  -- | Does the file path have an extension? (Windows) --@@ -169,6 +174,7 @@ -- False hasExtension :: FilePatherA' Bool hasExtension = mkKleisli' FP.hasExtension+{-# INLINE hasExtension #-}  -- | Split all extensions from a file path (Windows). --@@ -179,6 +185,7 @@ -- ("C:\\tmp\\foo","") splitExtensions :: FilePatherA' (FilePath, String) splitExtensions = mkKleisli' FP.splitExtensions+{-# INLINE splitExtensions #-}  -- | Get all extensions from a file path (Windows). --@@ -189,6 +196,7 @@ -- "" takeExtensions :: FilePatherA' String takeExtensions = mkKleisli' FP.takeExtensions+{-# INLINE takeExtensions #-}  -- | Drop all extensions from a file path (Windows). --@@ -199,6 +207,7 @@ -- "C:\\tmp\\foo" dropExtensions :: FilePatherA' FilePath dropExtensions = mkKleisli' FP.dropExtensions+{-# INLINE dropExtensions #-}  -- | Replace all extensions of a file path (Windows). --@@ -209,6 +218,7 @@ -- "C:\\tmp\\foo.a.b" replaceExtensions :: String -> FilePatherA' FilePath replaceExtensions s = mkKleisli' (`FP.replaceExtensions` s)+{-# INLINE replaceExtensions #-}  -- | Is the given string an extension of the file path? (Windows) --@@ -222,6 +232,7 @@ -- True isExtensionOf :: String -> FilePatherA' Bool isExtensionOf s = mkKleisli' (FP.isExtensionOf s)+{-# INLINE isExtensionOf #-}  -- | Strip an extension from a file path (Windows), returning 'Nothing' if -- it does not match.@@ -236,6 +247,7 @@ -- Just "C:\\tmp\\foo.tar" stripExtension :: String -> FilePatherMaybeA FilePath stripExtension s = Kleisli (FP.stripExtension s)+{-# INLINE stripExtension #-}  -- | Split a file path into directory and file components (Windows). --@@ -249,6 +261,7 @@ -- ("./","foo.hs") splitFileName :: FilePatherA' (String, String) splitFileName = mkKleisli' FP.splitFileName+{-# INLINE splitFileName #-}  -- | Get the file name component of a file path (Windows). --@@ -262,6 +275,7 @@ -- "foo.hs" takeFileName :: FilePatherA' FilePath takeFileName = mkKleisli' FP.takeFileName+{-# INLINE takeFileName #-}  -- | Replace the file name component of a file path (Windows). --@@ -272,6 +286,7 @@ -- "C:\\tmp\\baz" replaceFileName :: String -> FilePatherA' FilePath replaceFileName s = mkKleisli' (`FP.replaceFileName` s)+{-# INLINE replaceFileName #-}  -- | Drop the file name component of a file path (Windows). --@@ -282,6 +297,7 @@ -- "./" dropFileName :: FilePatherA' FilePath dropFileName = mkKleisli' FP.dropFileName+{-# INLINE dropFileName #-}  -- | Get the base name (file name without extension) of a file path (Windows). --@@ -295,6 +311,7 @@ -- "" takeBaseName :: FilePatherA' String takeBaseName = mkKleisli' FP.takeBaseName+{-# INLINE takeBaseName #-}  -- | Replace the base name of a file path (Windows). --@@ -305,6 +322,7 @@ -- "C:\\tmp\\quux.gz" replaceBaseName :: String -> FilePatherA' FilePath replaceBaseName s = mkKleisli' (`FP.replaceBaseName` s)+{-# INLINE replaceBaseName #-}  -- | Get the directory component of a file path (Windows). --@@ -318,6 +336,7 @@ -- "." takeDirectory :: FilePatherA' FilePath takeDirectory = mkKleisli' FP.takeDirectory+{-# INLINE takeDirectory #-}  -- | Replace the directory component of a file path (Windows). --@@ -328,6 +347,7 @@ -- "src\\foo.hs" replaceDirectory :: String -> FilePatherA' FilePath replaceDirectory s = mkKleisli' (`FP.replaceDirectory` s)+{-# INLINE replaceDirectory #-}  -- | Combine a directory path with a file path (Windows). --@@ -341,6 +361,7 @@ -- "src\\Data\\Foo.hs" combine :: FilePath -> FilePatherA' FilePath combine s = mkKleisli' (FP.combine s)+{-# INLINE combine #-}  -- | Split a file path into its path components (Windows). --@@ -351,6 +372,7 @@ -- ["src\\","foo.hs"] splitPath :: FilePatherA' [FilePath] splitPath = mkKleisli' FP.splitPath+{-# INLINE splitPath #-}  -- | Split a file path into its directory components (Windows). --@@ -361,6 +383,7 @@ -- ["C:\\"] splitDirectories :: FilePatherA' [FilePath] splitDirectories = mkKleisli' FP.splitDirectories+{-# INLINE splitDirectories #-}  -- | Split a file path into drive and remainder (Windows). --@@ -371,6 +394,7 @@ -- ("","tmp\\foo") splitDrive :: FilePatherA' (FilePath, FilePath) splitDrive = mkKleisli' FP.splitDrive+{-# INLINE splitDrive #-}  -- | Join a drive and the rest of a path (Windows). --@@ -381,6 +405,7 @@ -- "tmp\\foo" joinDrive :: FilePath -> FilePatherA' FilePath joinDrive s = mkKleisli' (FP.joinDrive s)+{-# INLINE joinDrive #-}  -- | Get the drive of a file path (Windows). --@@ -391,6 +416,7 @@ -- "" takeDrive :: FilePatherA' FilePath takeDrive = mkKleisli' FP.takeDrive+{-# INLINE takeDrive #-}  -- | Does the file path have a drive? (Windows) --@@ -401,6 +427,7 @@ -- False hasDrive :: FilePatherA' Bool hasDrive = mkKleisli' FP.hasDrive+{-# INLINE hasDrive #-}  -- | Drop the drive from a file path (Windows). --@@ -411,6 +438,7 @@ -- "tmp\\foo" dropDrive :: FilePatherA' FilePath dropDrive = mkKleisli' FP.dropDrive+{-# INLINE dropDrive #-}  -- | Is the file path a drive? (Windows) --@@ -421,6 +449,7 @@ -- False isDrive :: FilePatherA' Bool isDrive = mkKleisli' FP.isDrive+{-# INLINE isDrive #-}  -- | Does the file path have a trailing path separator? (Windows) --@@ -431,6 +460,7 @@ -- False hasTrailingPathSeparator :: FilePatherA' Bool hasTrailingPathSeparator = mkKleisli' FP.hasTrailingPathSeparator+{-# INLINE hasTrailingPathSeparator #-}  -- | Add a trailing path separator if one is not present (Windows). --@@ -441,6 +471,7 @@ -- "C:\\tmp\\" addTrailingPathSeparator :: FilePatherA' FilePath addTrailingPathSeparator = mkKleisli' FP.addTrailingPathSeparator+{-# INLINE addTrailingPathSeparator #-}  -- | Drop the trailing path separator if present (Windows). --@@ -454,6 +485,7 @@ -- "C:\\" dropTrailingPathSeparator :: FilePatherA' FilePath dropTrailingPathSeparator = mkKleisli' FP.dropTrailingPathSeparator+{-# INLINE dropTrailingPathSeparator #-}  -- | Normalise a file path (Windows). --@@ -467,6 +499,7 @@ -- "C:\\tmp\\foo" normalise :: FilePatherA' FilePath normalise = mkKleisli' FP.normalise+{-# INLINE normalise #-}  -- | Make a file path relative to a given directory (Windows). --@@ -480,6 +513,7 @@ -- "D:\\tmp\\foo.hs" makeRelative :: FilePath -> FilePatherA' FilePath makeRelative s = mkKleisli' (FP.makeRelative s)+{-# INLINE makeRelative #-}  -- | Are two file paths equal? (Windows, case-insensitive) --@@ -493,6 +527,7 @@ -- False equalFilePath :: FilePath -> FilePatherA' Bool equalFilePath s = mkKleisli' (FP.equalFilePath s)+{-# INLINE equalFilePath #-}  -- | Is the file path relative? (Windows) --@@ -506,6 +541,7 @@ -- True isRelative :: FilePatherA' Bool isRelative = mkKleisli' FP.isRelative+{-# INLINE isRelative #-}  -- | Is the file path absolute? (Windows) --@@ -519,6 +555,7 @@ -- True isAbsolute :: FilePatherA' Bool isAbsolute = mkKleisli' FP.isAbsolute+{-# INLINE isAbsolute #-}  -- | Is the file path valid? (Windows) --@@ -532,6 +569,7 @@ -- False isValid :: FilePatherA' Bool isValid = mkKleisli' FP.isValid+{-# INLINE isValid #-}  -- | Make a file path valid (Windows). --@@ -542,6 +580,7 @@ -- "C:\\tmp\\foo" makeValid :: FilePatherA' FilePath makeValid = mkKleisli' FP.makeValid+{-# INLINE makeValid #-}  -- | Combine two file paths (Windows). Synonym for 'combine'. --@@ -552,6 +591,7 @@ -- "src\\Data\\Foo.hs" (</>) :: FilePath -> FilePatherA' FilePath (</>) = combine+{-# INLINE (</>) #-}  -- | Add an extension (Windows). Synonym for 'addExtension'. --@@ -562,6 +602,7 @@ -- "C:\\tmp\\foo.tar.gz" (<.>) :: String -> FilePatherA' FilePath (<.>) = addExtension+{-# INLINE (<.>) #-}  -- | Replace the extension (Windows). Synonym for 'replaceExtension'. --@@ -572,3 +613,4 @@ -- "C:\\tmp\\foo.txt" (-<.>) :: String -> FilePatherA' FilePath (-<.>) = replaceExtension+{-# INLINE (-<.>) #-}