filepather 0.4.1 → 0.5
raw patch · 11 files changed
+580/−495 lines, 11 filesdep +containersdep −semigroupsdep ~basedep ~bytestringdep ~contravariantPVP ok
version bump matches the API change (PVP)
Dependencies added: containers
Dependencies removed: semigroups
Dependency ranges changed: base, bytestring, contravariant, directory, filepath, lens, mmorph, mtl, semigroupoids, time, transformers
API changes (from Hackage documentation)
- System.FilePath.FilePather.Compose: (-<<-) :: Bind f => ReadFilePathT f b -> ToFilePathT f a -> a -> f b
- System.FilePath.FilePather.Compose: (->>-) :: Bind f => ToFilePathT f a -> ReadFilePathT f b -> a -> f b
- System.FilePath.FilePather.Compose: composeReadTo :: Bind f => ReadFilePathT f b -> ToFilePathT f a -> a -> f b
- System.FilePath.FilePather.Compose: composeToRead :: Bind f => ToFilePathT f a -> ReadFilePathT f b -> a -> f b
- System.FilePath.FilePather.Compose: infixr 1 -<<-
- System.FilePath.FilePather.Find: always :: Applicative f => ReadFilePathT f Bool
- System.FilePath.FilePather.Find: findFilesAlways :: ReadFilePathT IO [FilePath]
- System.FilePath.FilePather.Find: findFilesBase :: ReadFilePathT IO Bool -> ReadFilePathT IO [FilePath]
- System.FilePath.FilePather.Find: findFilesBaseAlways :: ReadFilePathT IO [FilePath]
- System.FilePath.FilePather.Posix: (-<.>) :: FilePath -> String -> FilePath
- System.FilePath.FilePather.Posix: (</>) :: FilePath -> FilePath -> FilePath
- System.FilePath.FilePather.Posix: extSeparator :: Char
- System.FilePath.FilePather.Posix: infixr 5 </>
- System.FilePath.FilePather.Posix: infixr 7 -<.>
- System.FilePath.FilePather.Posix: isExtSeparator :: Char -> Bool
- System.FilePath.FilePather.Posix: isPathSeparator :: Char -> Bool
- System.FilePath.FilePather.Posix: joinPath :: ToFilePath [FilePath]
- System.FilePath.FilePather.Posix: pathSeparator :: Char
- System.FilePath.FilePather.Posix: pathSeparators :: [Char]
- System.FilePath.FilePather.Posix: splitSearchPath :: String -> [FilePath]
- System.FilePath.FilePather.ReadFilePath: ReadFilePathT :: (FilePath -> f a) -> ReadFilePathT f a
- System.FilePath.FilePather.ReadFilePath: hoistReadFilePath :: Applicative f => ReadFilePath a -> ReadFilePathT f a
- System.FilePath.FilePather.ReadFilePath: instance (Data.Functor.Bind.Class.Apply f, GHC.Base.Applicative f, GHC.Base.Monoid a) => GHC.Base.Monoid (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f a)
- System.FilePath.FilePather.ReadFilePath: instance (Data.Functor.Bind.Class.Apply f, GHC.Base.Semigroup a) => GHC.Base.Semigroup (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f a)
- System.FilePath.FilePather.ReadFilePath: instance (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f a GHC.Types.~ t) => Control.Lens.Wrapped.Rewrapped (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f' a') t
- System.FilePath.FilePather.ReadFilePath: instance Control.Lens.Wrapped.Wrapped (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f a)
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Cont.Class.MonadCont f => Control.Monad.Cont.Class.MonadCont (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Error.Class.MonadError e f => Control.Monad.Error.Class.MonadError e (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Fail.MonadFail f => Control.Monad.Fail.MonadFail (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Fix.MonadFix f => Control.Monad.Fix.MonadFix (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.IO.Class.MonadIO f => Control.Monad.IO.Class.MonadIO (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Morph.MFunctor System.FilePath.FilePather.ReadFilePath.ReadFilePathT
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Morph.MMonad System.FilePath.FilePather.ReadFilePath.ReadFilePathT
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.State.Class.MonadState GHC.IO.FilePath f => Control.Monad.State.Class.MonadState GHC.IO.FilePath (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Trans.Class.MonadTrans System.FilePath.FilePather.ReadFilePath.ReadFilePathT
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Writer.Class.MonadWriter GHC.IO.FilePath f => Control.Monad.Writer.Class.MonadWriter GHC.IO.FilePath (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Zip.MonadZip f => Control.Monad.Zip.MonadZip (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Data.Functor.Alt.Alt f => Data.Functor.Alt.Alt (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Data.Functor.Bind.Class.Apply f => Data.Functor.Bind.Class.Apply (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance Data.Functor.Bind.Class.Bind f => Data.Functor.Bind.Class.Bind (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Alternative f => GHC.Base.Alternative (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Applicative f => GHC.Base.Applicative (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Functor f => GHC.Base.Functor (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Monad f => Control.Monad.Reader.Class.MonadReader GHC.IO.FilePath (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Monad f => GHC.Base.Monad (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: instance GHC.Base.MonadPlus f => GHC.Base.MonadPlus (System.FilePath.FilePather.ReadFilePath.ReadFilePathT f)
- System.FilePath.FilePather.ReadFilePath: newtype ReadFilePathT f a
- System.FilePath.FilePather.ReadFilePath: type ReadFilePath a = ReadFilePathT Identity a
- System.FilePath.FilePather.ToFilePath: ToFilePathT :: (a -> f FilePath) -> ToFilePathT f a
- System.FilePath.FilePather.ToFilePath: instance Control.Lens.Wrapped.Wrapped (System.FilePath.FilePather.ToFilePath.ToFilePathT f a)
- System.FilePath.FilePather.ToFilePath: instance Data.Functor.Contravariant.Contravariant (System.FilePath.FilePather.ToFilePath.ToFilePathT f)
- System.FilePath.FilePather.ToFilePath: instance GHC.Base.Applicative f => Data.Functor.Contravariant.Divisible.Decidable (System.FilePath.FilePather.ToFilePath.ToFilePathT f)
- System.FilePath.FilePather.ToFilePath: instance GHC.Base.Applicative f => Data.Functor.Contravariant.Divisible.Divisible (System.FilePath.FilePather.ToFilePath.ToFilePathT f)
- System.FilePath.FilePather.ToFilePath: newtype ToFilePathT f a
- System.FilePath.FilePather.ToFilePath: toFilePath :: Iso (ToFilePath a) (ToFilePath a') (a -> FilePath) (a' -> FilePath)
- System.FilePath.FilePather.ToFilePath: toRead :: Iso (ToFilePathT f FilePath) (ToFilePathT f' FilePath) (ReadFilePathT f FilePath) (ReadFilePathT f' FilePath)
- System.FilePath.FilePather.ToFilePath: type ToFilePath a = ToFilePathT Identity a
+ System.FilePath.FilePather.ByteString: appendFileB :: Exception e => ByteString -> ReadFilePathT e IO ()
+ System.FilePath.FilePather.ByteString: fromFilePath :: Exception e => ReadFilePathT e IO ByteString
+ System.FilePath.FilePather.ByteString: readFileB :: Exception e => ReadFilePathT e IO ByteString
+ System.FilePath.FilePather.ByteString: writeFileB :: Exception e => ByteString -> ReadFilePathT e IO ()
+ System.FilePath.FilePather.Directory: XdgState :: XdgDirectory
+ System.FilePath.FilePather.Find: findAll :: Exception e => ReadFilePathT e IO [FilePath]
+ System.FilePath.FilePather.Find: findDirectories :: Exception e => ReadFilePathT e IO [FilePath]
+ System.FilePath.FilePather.Find: findWith :: Exception e => ReadFilePathT e IO Bool -> ReadFilePathT e IO [FilePath]
+ System.FilePath.FilePather.IO: appendFile :: Exception e => String -> ReadFilePathT e IO ()
+ System.FilePath.FilePather.IO: openBinaryFile :: Exception e => IOMode -> ReadFilePathT e IO Handle
+ System.FilePath.FilePather.IO: openBinaryTempFile :: Exception e => String -> ReadFilePathT e IO (FilePath, Handle)
+ System.FilePath.FilePather.IO: openBinaryTempFileWithDefaultPermissions :: Exception e => String -> ReadFilePathT e IO (FilePath, Handle)
+ System.FilePath.FilePather.IO: openFile :: Exception e => IOMode -> ReadFilePathT e IO Handle
+ System.FilePath.FilePather.IO: openTempFile :: Exception e => String -> ReadFilePathT e IO (FilePath, Handle)
+ System.FilePath.FilePather.IO: openTempFileWithDefaultPermissions :: Exception e => String -> ReadFilePathT e IO (FilePath, Handle)
+ System.FilePath.FilePather.IO: readFile :: Exception e => ReadFilePathT e IO String
+ System.FilePath.FilePather.IO: readFile' :: Exception e => ReadFilePathT e IO String
+ System.FilePath.FilePather.IO: withBinaryFile :: Exception e => IOMode -> (Handle -> IO r) -> ReadFilePathT e IO r
+ System.FilePath.FilePather.IO: withFile :: Exception e => IOMode -> (Handle -> IO r) -> ReadFilePathT e IO r
+ System.FilePath.FilePather.IO: writeFile :: Exception e => String -> ReadFilePathT e IO ()
+ System.FilePath.FilePather.ReadFilePath: data ReadFilePathT e f a
+ System.FilePath.FilePather.ReadFilePath: errorReadFilePath :: Functor f => (FilePath -> f e) -> ReadFilePathT e f a
+ System.FilePath.FilePather.ReadFilePath: instance (GHC.Base.Monad f, GHC.Base.Monoid a) => GHC.Base.Monoid (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f a)
+ System.FilePath.FilePather.ReadFilePath: instance (GHC.Base.Monad f, GHC.Base.Semigroup a) => GHC.Base.Semigroup (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f a)
+ System.FilePath.FilePather.ReadFilePath: instance (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f a GHC.Types.~ t) => Control.Lens.Wrapped.Rewrapped (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e' f' a') t
+ System.FilePath.FilePather.ReadFilePath: instance Control.Lens.Wrapped.Wrapped (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f a)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Cont.Class.MonadCont f => Control.Monad.Cont.Class.MonadCont (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Error.Class.MonadError e f => Control.Monad.Error.Class.MonadError e (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Fail.MonadFail f => Control.Monad.Fail.MonadFail (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Fix.MonadFix f => Control.Monad.Fix.MonadFix (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.IO.Class.MonadIO f => Control.Monad.IO.Class.MonadIO (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Morph.MFunctor (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Morph.MMonad (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.State.Class.MonadState GHC.IO.FilePath f => Control.Monad.State.Class.MonadState GHC.IO.FilePath (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Trans.Class.MonadTrans (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Writer.Class.MonadWriter GHC.IO.FilePath f => Control.Monad.Writer.Class.MonadWriter GHC.IO.FilePath (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance Control.Monad.Zip.MonadZip f => Control.Monad.Zip.MonadZip (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Functor f => GHC.Base.Functor (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Monad f => Control.Monad.Reader.Class.MonadReader GHC.IO.FilePath (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Monad f => Data.Functor.Alt.Alt (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Monad f => Data.Functor.Bind.Class.Apply (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Monad f => Data.Functor.Bind.Class.Bind (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Monad f => GHC.Base.Applicative (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: instance GHC.Base.Monad f => GHC.Base.Monad (System.FilePath.FilePather.ReadFilePath.ReadFilePathT e f)
+ System.FilePath.FilePather.ReadFilePath: maybeReadFilePath :: Functor f => (FilePath -> f (Maybe a)) -> ReadFilePathT () f a
+ System.FilePath.FilePather.ReadFilePath: pureReadFilePath :: Applicative f => ReadFilePath e a -> ReadFilePathT e f a
+ System.FilePath.FilePather.ReadFilePath: successReadFilePath :: Functor f => (FilePath -> f a) -> ReadFilePathT e f a
+ System.FilePath.FilePather.ReadFilePath: swapReadFilePath :: Functor f => Iso (ReadFilePathT e f a) (ReadFilePathT e' f a') (ReadFilePathT a f e) (ReadFilePathT a' f e')
+ System.FilePath.FilePather.ReadFilePath: tryReadFilePath :: Exception e => (FilePath -> IO a) -> ReadFilePathT e IO a
- System.FilePath.FilePather.Directory: canonicalizePath :: ReadFilePathT IO FilePath
+ System.FilePath.FilePather.Directory: canonicalizePath :: Exception e => ReadFilePathT e IO FilePath
- System.FilePath.FilePather.Directory: copyFile :: FilePath -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: copyFile :: Exception e => FilePath -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: copyFileWithMetadata :: FilePath -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: copyFileWithMetadata :: Exception e => FilePath -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: copyPermissions :: FilePath -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: copyPermissions :: Exception e => FilePath -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: createDirectory :: ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: createDirectory :: Exception e => ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: createDirectoryIfMissing :: Bool -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: createDirectoryIfMissing :: Exception e => Bool -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: createDirectoryLink :: FilePath -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: createDirectoryLink :: Exception e => FilePath -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: createFileLink :: FilePath -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: createFileLink :: Exception e => FilePath -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: doesDirectoryExist :: ReadFilePathT IO Bool
+ System.FilePath.FilePather.Directory: doesDirectoryExist :: ReadFilePathT e IO Bool
- System.FilePath.FilePather.Directory: doesFileExist :: ReadFilePathT IO Bool
+ System.FilePath.FilePather.Directory: doesFileExist :: ReadFilePathT e IO Bool
- System.FilePath.FilePather.Directory: doesPathExist :: ReadFilePathT IO Bool
+ System.FilePath.FilePather.Directory: doesPathExist :: ReadFilePathT e IO Bool
- System.FilePath.FilePather.Directory: findExecutable :: ReadFilePathT IO (Maybe FilePath)
+ System.FilePath.FilePather.Directory: findExecutable :: ReadFilePathT e IO (Maybe FilePath)
- System.FilePath.FilePather.Directory: findExecutables :: ReadFilePathT IO [FilePath]
+ System.FilePath.FilePather.Directory: findExecutables :: ReadFilePathT e IO [FilePath]
- System.FilePath.FilePather.Directory: findExecutablesInDirectories :: [FilePath] -> ReadFilePathT IO [FilePath]
+ System.FilePath.FilePather.Directory: findExecutablesInDirectories :: [FilePath] -> ReadFilePathT e IO [FilePath]
- System.FilePath.FilePather.Directory: findFile :: [FilePath] -> ReadFilePathT IO (Maybe FilePath)
+ System.FilePath.FilePather.Directory: findFile :: [FilePath] -> ReadFilePathT e IO (Maybe FilePath)
- System.FilePath.FilePather.Directory: findFileWith :: ReadFilePathT IO Bool -> [FilePath] -> ReadFilePathT IO (Maybe FilePath)
+ System.FilePath.FilePather.Directory: findFileWith :: ReadFilePathT () IO () -> [FilePath] -> ReadFilePathT () IO FilePath
- System.FilePath.FilePather.Directory: findFiles :: [FilePath] -> ReadFilePathT IO [FilePath]
+ System.FilePath.FilePather.Directory: findFiles :: [FilePath] -> ReadFilePathT e IO [FilePath]
- System.FilePath.FilePather.Directory: findFilesWith :: ReadFilePathT IO Bool -> [FilePath] -> ReadFilePathT IO [FilePath]
+ System.FilePath.FilePather.Directory: findFilesWith :: ReadFilePathT () IO () -> [FilePath] -> ReadFilePathT e' IO [FilePath]
- System.FilePath.FilePather.Directory: getAccessTime :: ReadFilePathT IO UTCTime
+ System.FilePath.FilePather.Directory: getAccessTime :: Exception e => ReadFilePathT e IO UTCTime
- System.FilePath.FilePather.Directory: getAppUserDataDirectory :: ReadFilePathT IO FilePath
+ System.FilePath.FilePather.Directory: getAppUserDataDirectory :: Exception e => ReadFilePathT e IO FilePath
- System.FilePath.FilePather.Directory: getDirectoryContents :: ReadFilePathT IO [FilePath]
+ System.FilePath.FilePather.Directory: getDirectoryContents :: Exception e => ReadFilePathT e IO [FilePath]
- System.FilePath.FilePather.Directory: getFileSize :: ReadFilePathT IO Integer
+ System.FilePath.FilePather.Directory: getFileSize :: Exception e => ReadFilePathT e IO Integer
- System.FilePath.FilePather.Directory: getModificationTime :: ReadFilePathT IO UTCTime
+ System.FilePath.FilePather.Directory: getModificationTime :: Exception e => ReadFilePathT e IO UTCTime
- System.FilePath.FilePather.Directory: getPermissions :: ReadFilePathT IO Permissions
+ System.FilePath.FilePather.Directory: getPermissions :: Exception e => ReadFilePathT e IO Permissions
- System.FilePath.FilePather.Directory: getSymbolicLinkTarget :: ReadFilePathT IO FilePath
+ System.FilePath.FilePather.Directory: getSymbolicLinkTarget :: Exception e => ReadFilePathT e IO FilePath
- System.FilePath.FilePather.Directory: getXdgDirectory :: XdgDirectory -> ReadFilePathT IO FilePath
+ System.FilePath.FilePather.Directory: getXdgDirectory :: Exception e => XdgDirectory -> ReadFilePathT e IO FilePath
- System.FilePath.FilePather.Directory: listDirectory :: ReadFilePathT IO [FilePath]
+ System.FilePath.FilePather.Directory: listDirectory :: Exception e => ReadFilePathT e IO [FilePath]
- System.FilePath.FilePather.Directory: makeAbsolute :: ReadFilePathT IO FilePath
+ System.FilePath.FilePather.Directory: makeAbsolute :: Exception e => ReadFilePathT e IO FilePath
- System.FilePath.FilePather.Directory: makeRelativeToCurrentDirectory :: ReadFilePathT IO FilePath
+ System.FilePath.FilePather.Directory: makeRelativeToCurrentDirectory :: Exception e => ReadFilePathT e IO FilePath
- System.FilePath.FilePather.Directory: pathIsSymbolicLink :: ReadFilePathT IO Bool
+ System.FilePath.FilePather.Directory: pathIsSymbolicLink :: Exception e => ReadFilePathT e IO Bool
- System.FilePath.FilePather.Directory: removeDirectory :: ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: removeDirectory :: Exception e => ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: removeDirectoryLink :: ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: removeDirectoryLink :: Exception e => ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: removeDirectoryRecursive :: ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: removeDirectoryRecursive :: Exception e => ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: removeFile :: ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: removeFile :: Exception e => ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: removePathForcibly :: ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: removePathForcibly :: Exception e => ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: renameDirectory :: FilePath -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: renameDirectory :: Exception e => FilePath -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: renameFile :: FilePath -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: renameFile :: Exception e => FilePath -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: renamePath :: FilePath -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: renamePath :: Exception e => FilePath -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: setAccessTime :: UTCTime -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: setAccessTime :: Exception e => UTCTime -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: setModificationTime :: UTCTime -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: setModificationTime :: Exception e => UTCTime -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: setPermissions :: Permissions -> ReadFilePathT IO ()
+ System.FilePath.FilePather.Directory: setPermissions :: Exception e => Permissions -> ReadFilePathT1 e IO
- System.FilePath.FilePather.Directory: withCurrentDirectory :: IO a -> ReadFilePathT IO a
+ System.FilePath.FilePather.Directory: withCurrentDirectory :: Exception e => IO a -> ReadFilePathT e IO a
- System.FilePath.FilePather.Find: findAllFiles :: ReadFilePathT IO Bool -> ReadFilePathT IO [FilePath]
+ System.FilePath.FilePather.Find: findAllFiles :: Exception e => ReadFilePathT e IO [FilePath]
- System.FilePath.FilePather.Posix: addExtension :: Applicative f => ReadFilePathT f (String -> FilePath)
+ System.FilePath.FilePather.Posix: addExtension :: Applicative f => String -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: addTrailingPathSeparator :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: addTrailingPathSeparator :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: combine :: Applicative f => ReadFilePathT f (FilePath -> FilePath)
+ System.FilePath.FilePather.Posix: combine :: Applicative f => FilePath -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: dropDrive :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: dropDrive :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: dropExtension :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: dropExtension :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: dropExtensions :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: dropExtensions :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: dropFileName :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: dropFileName :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: dropTrailingPathSeparator :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: dropTrailingPathSeparator :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: equalFilePath :: Applicative f => ReadFilePathT f (FilePath -> Bool)
+ System.FilePath.FilePather.Posix: equalFilePath :: Applicative f => FilePath -> ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: hasDrive :: Applicative f => ReadFilePathT f Bool
+ System.FilePath.FilePather.Posix: hasDrive :: Applicative f => ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: hasExtension :: Applicative f => ReadFilePathT f Bool
+ System.FilePath.FilePather.Posix: hasExtension :: Applicative f => ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: hasTrailingPathSeparator :: Applicative f => ReadFilePathT f Bool
+ System.FilePath.FilePather.Posix: hasTrailingPathSeparator :: Applicative f => ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: isAbsolute :: Applicative f => ReadFilePathT f Bool
+ System.FilePath.FilePather.Posix: isAbsolute :: Applicative f => ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: isDrive :: Applicative f => ReadFilePathT f Bool
+ System.FilePath.FilePather.Posix: isDrive :: Applicative f => ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: isExtensionOf :: Applicative f => String -> ReadFilePathT f Bool
+ System.FilePath.FilePather.Posix: isExtensionOf :: Applicative f => String -> ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: isRelative :: Applicative f => ReadFilePathT f Bool
+ System.FilePath.FilePather.Posix: isRelative :: Applicative f => ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: isValid :: Applicative f => ReadFilePathT f Bool
+ System.FilePath.FilePather.Posix: isValid :: Applicative f => ReadFilePathT e f Bool
- System.FilePath.FilePather.Posix: joinDrive :: Applicative f => ReadFilePathT f (FilePath -> FilePath)
+ System.FilePath.FilePather.Posix: joinDrive :: Applicative f => FilePath -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: makeRelative :: Applicative f => ReadFilePathT f (FilePath -> FilePath)
+ System.FilePath.FilePather.Posix: makeRelative :: Applicative f => FilePath -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: makeValid :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: makeValid :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: normalise :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: normalise :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: replaceBaseName :: Applicative f => ReadFilePathT f (String -> FilePath)
+ System.FilePath.FilePather.Posix: replaceBaseName :: Applicative f => String -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: replaceDirectory :: Applicative f => ReadFilePathT f (String -> FilePath)
+ System.FilePath.FilePather.Posix: replaceDirectory :: Applicative f => String -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: replaceExtension :: Applicative f => ReadFilePathT f (String -> FilePath)
+ System.FilePath.FilePather.Posix: replaceExtension :: Applicative f => String -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: replaceExtensions :: Applicative f => ReadFilePathT f (String -> FilePath)
+ System.FilePath.FilePather.Posix: replaceExtensions :: Applicative f => String -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: replaceFileName :: Applicative f => ReadFilePathT f (String -> FilePath)
+ System.FilePath.FilePather.Posix: replaceFileName :: Applicative f => String -> ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: splitDirectories :: Applicative f => ReadFilePathT f [FilePath]
+ System.FilePath.FilePather.Posix: splitDirectories :: Applicative f => ReadFilePathT e f [FilePath]
- System.FilePath.FilePather.Posix: splitDrive :: Applicative f => ReadFilePathT f (FilePath, FilePath)
+ System.FilePath.FilePather.Posix: splitDrive :: Applicative f => ReadFilePathT e f (FilePath, FilePath)
- System.FilePath.FilePather.Posix: splitExtension :: Applicative f => ReadFilePathT f (String, String)
+ System.FilePath.FilePather.Posix: splitExtension :: Applicative f => ReadFilePathT e f (String, String)
- System.FilePath.FilePather.Posix: splitExtensions :: Applicative f => ReadFilePathT f (FilePath, String)
+ System.FilePath.FilePather.Posix: splitExtensions :: Applicative f => ReadFilePathT e f (FilePath, String)
- System.FilePath.FilePather.Posix: splitFileName :: Applicative f => ReadFilePathT f (String, String)
+ System.FilePath.FilePather.Posix: splitFileName :: Applicative f => ReadFilePathT e f (String, String)
- System.FilePath.FilePather.Posix: splitPath :: Applicative f => ReadFilePathT f [FilePath]
+ System.FilePath.FilePather.Posix: splitPath :: Applicative f => ReadFilePathT e f [FilePath]
- System.FilePath.FilePather.Posix: stripExtension :: Applicative f => String -> ReadFilePathT f (Maybe FilePath)
+ System.FilePath.FilePather.Posix: stripExtension :: Applicative f => String -> ReadFilePathT e f (Maybe FilePath)
- System.FilePath.FilePather.Posix: takeBaseName :: Applicative f => ReadFilePathT f String
+ System.FilePath.FilePather.Posix: takeBaseName :: Applicative f => ReadFilePathT e f String
- System.FilePath.FilePather.Posix: takeDirectory :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: takeDirectory :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: takeDrive :: Applicative f => ReadFilePathT f FilePath
+ System.FilePath.FilePather.Posix: takeDrive :: Applicative f => ReadFilePathT e f FilePath
- System.FilePath.FilePather.Posix: takeExtension :: Applicative f => ReadFilePathT f String
+ System.FilePath.FilePather.Posix: takeExtension :: Applicative f => ReadFilePathT e f String
- System.FilePath.FilePather.Posix: takeExtensions :: Applicative f => ReadFilePathT f String
+ System.FilePath.FilePather.Posix: takeExtensions :: Applicative f => ReadFilePathT e f String
- System.FilePath.FilePather.Posix: takeFileName :: Applicative f => ReadFilePathT f String
+ System.FilePath.FilePather.Posix: takeFileName :: Applicative f => ReadFilePathT e f String
- System.FilePath.FilePather.ReadFilePath: liftReadFilePath :: Applicative f => (FilePath -> a) -> ReadFilePathT f a
+ System.FilePath.FilePather.ReadFilePath: liftReadFilePath :: Applicative f => (FilePath -> a) -> ReadFilePathT e f a
- System.FilePath.FilePather.ReadFilePath: readFilePath :: Iso (ReadFilePath a) (ReadFilePath a') (FilePath -> a) (FilePath -> a')
+ System.FilePath.FilePather.ReadFilePath: readFilePath :: Iso (ReadFilePath e a) (ReadFilePath e' a') (FilePath -> Either e a) (FilePath -> Either e' a')
- System.FilePath.FilePather.ReadFilePath: type ReadFilePath1 f = ReadFilePath ()
+ System.FilePath.FilePather.ReadFilePath: type ReadFilePath1 e f = ReadFilePath e ()
- System.FilePath.FilePather.ReadFilePath: type ReadFilePathT1 f = ReadFilePathT f ()
+ System.FilePath.FilePather.ReadFilePath: type ReadFilePathT1 e f = ReadFilePathT e f ()
Files
- changelog.md +7/−0
- filepather.cabal +18/−18
- src/System/FilePath/FilePather.hs +2/−2
- src/System/FilePath/FilePather/ByteString.hs +42/−0
- src/System/FilePath/FilePather/Compose.hs +0/−55
- src/System/FilePath/FilePather/Directory.hs +123/−89
- src/System/FilePath/FilePather/Find.hs +53/−83
- src/System/FilePath/FilePather/IO.hs +121/−0
- src/System/FilePath/FilePather/Posix.hs +61/−60
- src/System/FilePath/FilePather/ReadFilePath.hs +153/−111
- src/System/FilePath/FilePather/ToFilePath.hs +0/−77
changelog.md view
@@ -1,3 +1,10 @@+0.5++* Introduce `Either` into filepath reader+* Remove `ToFilePath`+* Remove some functions that do not fit+* Update GHC version requirement >= 9+ 0.4.1 * Add `System.Directory`
filepather.cabal view
@@ -1,5 +1,5 @@ name: filepather-version: 0.4.1+version: 0.5 synopsis: Functions on System.FilePath description: Functions over @System.FilePath@ including a find function for recursing down directories.@@ -7,14 +7,14 @@ license-file: LICENCE author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> maintainer: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>-copyright: Copyright (C) 2021 Tony Morris+copyright: Copyright (C) 2021-2023 Tony Morris category: Test build-type: Simple extra-source-files: changelog.md cabal-version: >=1.10 homepage: https://gitlab.com/tonymorris/filepather bug-reports: https://gitlab.com/tonymorris/filepather/issues-tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3, GHC == 8.6.5+tested-with: GHC == 9.0.2 source-repository head type: git@@ -23,25 +23,25 @@ library exposed-modules: System.FilePath.FilePather- System.FilePath.FilePather.Compose+ System.FilePath.FilePather.ByteString System.FilePath.FilePather.Directory System.FilePath.FilePather.Find- System.FilePath.FilePather.ReadFilePath- System.FilePath.FilePather.ToFilePath+ System.FilePath.FilePather.IO System.FilePath.FilePather.Posix+ System.FilePath.FilePather.ReadFilePath - build-depends: base >= 4.8 && < 6- , bytestring >= 0.10 && < 0.12- , contravariant >= 1 && < 2- , directory >= 1.3 && < 2- , filepath >= 1.4 && < 2- , lens >= 4 && < 6- , mmorph >= 1.1 && < 2- , mtl >= 2.2 && < 2.3- , semigroups >= 0.9 && < 1- , semigroupoids >= 5.2 && < 6- , time >= 1.2 && < 2- , transformers >= 0.5 && < 0.7+ build-depends: base >= 4.15 && < 6+ , bytestring >= 0.11.2.0 && < 0.12+ , containers >= 0.6.4.1 && < 0.7+ , contravariant >= 1.5.5 && < 2+ , directory >= 1.3.7.1 && < 2+ , filepath >= 1.4.2.1 && < 2+ , lens >= 5.2.3 && < 6+ , mmorph >= 1.2.0 && < 2+ , mtl >= 2.2.2 && < 3+ , semigroupoids >= 6.0.0.1 && < 7+ , time >= 1.9.3 && < 2+ , transformers >= 0.5.6.2 && < 0.6 hs-source-dirs: src default-language: Haskell2010
src/System/FilePath/FilePather.hs view
@@ -2,9 +2,9 @@ module P ) where -import System.FilePath.FilePather.Compose as P+import System.FilePath.FilePather.ByteString as P import System.FilePath.FilePather.Directory as P import System.FilePath.FilePather.Find as P+import System.FilePath.FilePather.IO as P import System.FilePath.FilePather.Posix as P import System.FilePath.FilePather.ReadFilePath as P-import System.FilePath.FilePather.ToFilePath as P
+ src/System/FilePath/FilePather/ByteString.hs view
@@ -0,0 +1,42 @@+{-# OPTIONS_GHC -Wall #-}+{-# LANGUAGE NoImplicitPrelude #-}++module System.FilePath.FilePather.ByteString(+ fromFilePath+, readFileB+, writeFileB+, appendFileB+) where++import Control.Exception ( Exception )+import Data.ByteString( ByteString )+import qualified Data.ByteString as B+import System.FilePath.FilePather.ReadFilePath+ ( ReadFilePathT, tryReadFilePath )+import System.IO ( IO )++fromFilePath ::+ Exception e =>+ ReadFilePathT e IO ByteString+fromFilePath =+ tryReadFilePath B.fromFilePath++readFileB ::+ Exception e =>+ ReadFilePathT e IO ByteString+readFileB =+ tryReadFilePath B.readFile++writeFileB ::+ Exception e =>+ ByteString+ -> ReadFilePathT e IO ()+writeFileB s =+ tryReadFilePath (`B.writeFile` s)++appendFileB ::+ Exception e =>+ ByteString+ -> ReadFilePathT e IO ()+appendFileB s =+ tryReadFilePath (`B.appendFile` s)
− src/System/FilePath/FilePather/Compose.hs
@@ -1,55 +0,0 @@-{-# OPTIONS_GHC -Wall #-}-{-# LANGUAGE NoImplicitPrelude #-}--module System.FilePath.FilePather.Compose(- composeToRead-, (->>-)-, composeReadTo-, (-<<-)-) where--import Control.Lens ( view, Wrapped(_Wrapped') )-import Data.Functor.Bind ( (-<-), (->-), Bind )-import System.FilePath.FilePather.ReadFilePath- ( ReadFilePathT(..) )-import System.FilePath.FilePather.ToFilePath ( ToFilePathT(..) )--composeToRead ::- Bind f =>- ToFilePathT f a- -> ReadFilePathT f b- -> a- -> f b-composeToRead f g =- view _Wrapped' f ->- view _Wrapped' g--(->>-) ::- Bind f =>- ToFilePathT f a- -> ReadFilePathT f b- -> a- -> f b-(->>-) =- composeToRead--infixr 1 ->>---composeReadTo ::- Bind f =>- ReadFilePathT f b- -> ToFilePathT f a- -> a- -> f b-composeReadTo f g =- view _Wrapped' f -<- view _Wrapped' g--(-<<-) ::- Bind f =>- ReadFilePathT f b- -> ToFilePathT f a- -> a- -> f b-(-<<-) =- composeReadTo--infixr 1 -<<-
src/System/FilePath/FilePather/Directory.hs view
@@ -48,245 +48,279 @@ ) where import Control.Category ( Category((.)) )+import Control.Exception ( Exception ) import Control.Lens ( over, _Wrapped )-import Data.Maybe ( Maybe )-import Data.Bool ( Bool )+import Data.Maybe ( Maybe, maybe )+import Data.Bool ( Bool(..) )+import Data.Either ( Either(Right, Left), either )+import Data.Functor ( Functor(fmap) ) import Data.Time ( UTCTime ) import GHC.Num( Integer ) import qualified System.Directory as D import System.Directory as SD(getCurrentDirectory, getHomeDirectory, XdgDirectory(..), XdgDirectoryList(..), getXdgDirectoryList, getUserDocumentsDirectory, getTemporaryDirectory, exeExtension, Permissions(..), emptyPermissions, readable, writable, executable, searchable, setOwnerReadable, setOwnerWritable, setOwnerExecutable, setOwnerSearchable) import System.FilePath.FilePather.ReadFilePath- ( ReadFilePathT(..) ) import System.FilePath ( FilePath ) import System.IO ( IO ) createDirectory ::- ReadFilePathT IO ()+ Exception e =>+ ReadFilePathT1 e IO createDirectory =- ReadFilePathT D.createDirectory+ tryReadFilePath D.createDirectory createDirectoryIfMissing ::+ Exception e => Bool- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO createDirectoryIfMissing =- ReadFilePathT . D.createDirectoryIfMissing+ tryReadFilePath . D.createDirectoryIfMissing removeDirectory ::- ReadFilePathT IO ()+ Exception e =>+ ReadFilePathT1 e IO removeDirectory =- ReadFilePathT D.removeDirectory+ tryReadFilePath D.removeDirectory removeDirectoryRecursive ::- ReadFilePathT IO ()+ Exception e =>+ ReadFilePathT1 e IO removeDirectoryRecursive =- ReadFilePathT D.removeDirectoryRecursive+ tryReadFilePath D.removeDirectoryRecursive removePathForcibly ::- ReadFilePathT IO ()+ Exception e =>+ ReadFilePathT1 e IO removePathForcibly =- ReadFilePathT D.removePathForcibly+ tryReadFilePath D.removePathForcibly renameDirectory ::+ Exception e => FilePath- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO renameDirectory =- ReadFilePathT . D.renameDirectory+ tryReadFilePath . D.renameDirectory listDirectory ::- ReadFilePathT IO [FilePath]+ Exception e =>+ ReadFilePathT e IO [FilePath] listDirectory =- ReadFilePathT D.listDirectory+ tryReadFilePath D.listDirectory getDirectoryContents ::- ReadFilePathT IO [FilePath]+ Exception e =>+ ReadFilePathT e IO [FilePath] getDirectoryContents =- ReadFilePathT D.listDirectory+ tryReadFilePath D.listDirectory withCurrentDirectory ::+ Exception e => IO a- -> ReadFilePathT IO a+ -> ReadFilePathT e IO a withCurrentDirectory io =- ReadFilePathT (`D.withCurrentDirectory` io)+ tryReadFilePath (`D.withCurrentDirectory` io) getXdgDirectory ::+ Exception e => XdgDirectory- -> ReadFilePathT IO FilePath+ -> ReadFilePathT e IO FilePath getXdgDirectory xdg =- ReadFilePathT (D.getXdgDirectory xdg)+ tryReadFilePath (D.getXdgDirectory xdg) getAppUserDataDirectory ::- ReadFilePathT IO FilePath+ Exception e =>+ ReadFilePathT e IO FilePath getAppUserDataDirectory =- ReadFilePathT D.getAppUserDataDirectory+ tryReadFilePath D.getAppUserDataDirectory removeFile ::- ReadFilePathT IO ()+ Exception e =>+ ReadFilePathT1 e IO removeFile =- ReadFilePathT D.removeFile+ tryReadFilePath D.removeFile renameFile ::+ Exception e => FilePath- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO renameFile =- ReadFilePathT . D.renameFile+ tryReadFilePath . D.renameFile renamePath ::+ Exception e => FilePath- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO renamePath =- ReadFilePathT . D.renamePath+ tryReadFilePath . D.renamePath copyFile ::+ Exception e => FilePath- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO copyFile =- ReadFilePathT . D.copyFile+ tryReadFilePath . D.copyFile copyFileWithMetadata ::+ Exception e => FilePath- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO copyFileWithMetadata =- ReadFilePathT . D.copyFileWithMetadata+ tryReadFilePath . D.copyFileWithMetadata getFileSize ::- ReadFilePathT IO Integer+ Exception e =>+ ReadFilePathT e IO Integer getFileSize =- ReadFilePathT D.getFileSize+ tryReadFilePath D.getFileSize canonicalizePath ::- ReadFilePathT IO FilePath+ Exception e =>+ ReadFilePathT e IO FilePath canonicalizePath =- ReadFilePathT D.canonicalizePath+ tryReadFilePath D.canonicalizePath makeAbsolute ::- ReadFilePathT IO FilePath+ Exception e =>+ ReadFilePathT e IO FilePath makeAbsolute =- ReadFilePathT D.makeAbsolute+ tryReadFilePath D.makeAbsolute makeRelativeToCurrentDirectory ::- ReadFilePathT IO FilePath+ Exception e =>+ ReadFilePathT e IO FilePath makeRelativeToCurrentDirectory =- ReadFilePathT D.makeRelativeToCurrentDirectory+ tryReadFilePath D.makeRelativeToCurrentDirectory doesPathExist ::- ReadFilePathT IO Bool+ ReadFilePathT e IO Bool doesPathExist =- ReadFilePathT D.doesPathExist+ successReadFilePath D.doesPathExist doesFileExist ::- ReadFilePathT IO Bool+ ReadFilePathT e IO Bool doesFileExist =- ReadFilePathT D.doesFileExist+ successReadFilePath D.doesFileExist doesDirectoryExist ::- ReadFilePathT IO Bool+ ReadFilePathT e IO Bool doesDirectoryExist =- ReadFilePathT D.doesDirectoryExist+ successReadFilePath D.doesDirectoryExist findExecutable ::- ReadFilePathT IO (Maybe FilePath)+ ReadFilePathT e IO (Maybe FilePath) findExecutable =- ReadFilePathT D.findExecutable+ successReadFilePath D.findExecutable findExecutables ::- ReadFilePathT IO [FilePath]+ ReadFilePathT e IO [FilePath] findExecutables =- ReadFilePathT D.findExecutables+ successReadFilePath D.findExecutables findExecutablesInDirectories :: [FilePath]- -> ReadFilePathT IO [FilePath]+ -> ReadFilePathT e IO [FilePath] findExecutablesInDirectories =- ReadFilePathT . D.findExecutablesInDirectories+ successReadFilePath . D.findExecutablesInDirectories findFile :: [FilePath]- -> ReadFilePathT IO (Maybe FilePath)+ -> ReadFilePathT e IO (Maybe FilePath) findFile =- ReadFilePathT . D.findFile+ successReadFilePath . D.findFile findFiles :: [FilePath]- -> ReadFilePathT IO [FilePath]+ -> ReadFilePathT e IO [FilePath] findFiles =- ReadFilePathT . D.findFiles+ successReadFilePath . D.findFiles findFileWith ::- ReadFilePathT IO Bool+ ReadFilePathT () IO () -> [FilePath]- -> ReadFilePathT IO (Maybe FilePath)+ -> ReadFilePathT () IO FilePath findFileWith x ps =- over _Wrapped (`D.findFileWith` ps) x+ over _Wrapped (\k -> fmap (maybe (Left ()) Right) . D.findFileWith (fmap (either (\() -> False) (\() -> True)) . k) ps) x findFilesWith ::- ReadFilePathT IO Bool+ ReadFilePathT () IO () -> [FilePath]- -> ReadFilePathT IO [FilePath]+ -> ReadFilePathT e' IO [FilePath] findFilesWith x ps =- over _Wrapped (`D.findFilesWith` ps) x+ over _Wrapped (\w -> fmap Right . D.findFilesWith (fmap (either (\() -> False) (\() -> True)) . w) ps) x createFileLink ::+ Exception e => FilePath- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO createFileLink =- ReadFilePathT . D.createFileLink+ tryReadFilePath . D.createFileLink createDirectoryLink ::+ Exception e => FilePath- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO createDirectoryLink =- ReadFilePathT . D.createDirectoryLink+ tryReadFilePath . D.createDirectoryLink removeDirectoryLink ::- ReadFilePathT IO ()+ Exception e =>+ ReadFilePathT1 e IO removeDirectoryLink =- ReadFilePathT D.removeDirectoryLink+ tryReadFilePath D.removeDirectoryLink pathIsSymbolicLink ::- ReadFilePathT IO Bool+ Exception e =>+ ReadFilePathT e IO Bool pathIsSymbolicLink =- ReadFilePathT D.pathIsSymbolicLink+ tryReadFilePath D.pathIsSymbolicLink getSymbolicLinkTarget ::- ReadFilePathT IO FilePath+ Exception e =>+ ReadFilePathT e IO FilePath getSymbolicLinkTarget =- ReadFilePathT D.getSymbolicLinkTarget+ tryReadFilePath D.getSymbolicLinkTarget getPermissions ::- ReadFilePathT IO Permissions+ Exception e =>+ ReadFilePathT e IO Permissions getPermissions =- ReadFilePathT D.getPermissions+ tryReadFilePath D.getPermissions setPermissions ::+ Exception e => Permissions- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO setPermissions p =- ReadFilePathT (`D.setPermissions` p)+ tryReadFilePath (`D.setPermissions` p) copyPermissions ::+ Exception e => FilePath- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO copyPermissions =- ReadFilePathT . D.copyPermissions+ tryReadFilePath . D.copyPermissions getAccessTime ::- ReadFilePathT IO UTCTime+ Exception e =>+ ReadFilePathT e IO UTCTime getAccessTime =- ReadFilePathT D.getAccessTime+ tryReadFilePath D.getAccessTime getModificationTime ::- ReadFilePathT IO UTCTime+ Exception e =>+ ReadFilePathT e IO UTCTime getModificationTime =- ReadFilePathT D.getModificationTime+ tryReadFilePath D.getModificationTime setAccessTime ::+ Exception e => UTCTime- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO setAccessTime u =- ReadFilePathT (`D.setAccessTime` u)+ tryReadFilePath (`D.setAccessTime` u) setModificationTime ::+ Exception e => UTCTime- -> ReadFilePathT IO ()+ -> ReadFilePathT1 e IO setModificationTime u =- ReadFilePathT (`D.setModificationTime` u)+ tryReadFilePath (`D.setModificationTime` u)
src/System/FilePath/FilePather/Find.hs view
@@ -2,93 +2,63 @@ {-# LANGUAGE NoImplicitPrelude #-} module System.FilePath.FilePather.Find(- findAllFiles-, always-, findFilesAlways-, findFilesBase-, findFilesBaseAlways+ findWith+, findDirectories+, findAll+, findAllFiles ) where -import Control.Applicative ( Applicative(liftA2, pure) )-import Control.Category ( Category(id) )-import Control.Lens ( view )-import Control.Monad ( join, Monad((>>=)) )-import Control.Monad.Reader.Class ( MonadReader(ask) )-import System.FilePath.FilePather.Posix- ( (</>), FilePath, dropTrailingPathSeparator )-import System.IO ( IO )-import Data.Bool ( Bool(True), bool )-import Data.Function(($))-import Data.Functor ( Functor(fmap) )-import Data.Traversable ( Traversable(traverse) )+import Control.Applicative ( Applicative(pure) )+import Control.Category ( Category((.)) )+import Control.Exception ( Exception )+import Control.Lens ( view, _Wrapped )+import Control.Monad ( Monad((>>=)), filterM )+import Control.Monad.IO.Class ( MonadIO(liftIO) )+import Control.Monad.Reader ( MonadReader(local, ask) )+import Data.Bool ( Bool(True) )+import Data.Foldable ( fold )+import Data.Functor ( Functor(fmap), (<$>) ) import Data.Semigroup ( Semigroup((<>)) )-import System.Directory(doesDirectoryExist, listDirectory)-import System.FilePath.FilePather.ReadFilePath- ( ReadFilePathT(..), readFilePath )--findAllFiles ::- ReadFilePathT IO Bool- -> ReadFilePathT IO [FilePath]-findAllFiles (ReadFilePathT test) =- let bool' ::- Monad f =>- f a- -> f a- -> f Bool- -> f a- bool' f t p =- p >>= bool f t- partitionM ::- Applicative m =>- (a -> m Bool)- -> [a]- -> m ([a], [a])- partitionM _ [] =- pure ([], [])- partitionM f (x:xs) =- liftA2- (\res (as, bs) ->- let onres p q =- bool p q res- in (onres id (x:) as, onres (x:) id bs)- )- (f x)- (partitionM f xs)- findFiles' base dx =- bool'- (pure [])- (- let findFiles'' dir =- let dir' =- base </> dir- in do (dirs,files) <- listDirectory dir' >>= partitionM (\d -> doesDirectoryExist (dir' </> d))- rest <- fmap join (traverse (\d -> findFiles'' (dir </> d)) dirs)- pure (fmap (dir </>) files <> rest)- in findFiles'' dx- )- (test $ view readFilePath dropTrailingPathSeparator dx)- in ReadFilePathT (`findFiles'` "")+import Data.Traversable ( Traversable(traverse) )+import System.FilePath ( FilePath, (</>) )+import System.FilePath.FilePather.Directory+ ( listDirectory, doesFileExist, doesDirectoryExist )+import System.FilePath.FilePather.ReadFilePath ( ReadFilePathT )+import System.IO ( IO )+import System.IO.Unsafe( unsafeInterleaveIO ) -always ::- Applicative f =>- ReadFilePathT f Bool-always =- pure True+findWith ::+ Exception e =>+ ReadFilePathT e IO Bool+ -> ReadFilePathT e IO [FilePath]+findWith p =+ let setl =+ local . pure+ in do z <- ask+ a <- listDirectory+ b <- filterM (`setl` p) ((z </>) <$> a)+ d <- filterM (`setl` doesDirectoryExist) b+ case d of+ [] ->+ pure b+ _ ->+ do n <- liftIO (unsafeInterleaveIO (fmap (>>= fold) (traverse (view _Wrapped (findWith p)) d)))+ pure (b <> n) -findFilesAlways ::- ReadFilePathT IO [FilePath]-findFilesAlways =- findAllFiles always+findDirectories ::+ Exception e =>+ ReadFilePathT e IO [FilePath]+findDirectories =+ findWith doesDirectoryExist -findFilesBase ::- ReadFilePathT IO Bool- -> ReadFilePathT IO [FilePath]-findFilesBase r =- do p <- ask- z <- findAllFiles r- pure (fmap (p </>) z)+findAll ::+ Exception e =>+ ReadFilePathT e IO [FilePath]+findAll =+ findWith (pure True) -findFilesBaseAlways ::- ReadFilePathT IO [FilePath]-findFilesBaseAlways =- findFilesBase always+findAllFiles ::+ Exception e =>+ ReadFilePathT e IO [FilePath]+findAllFiles =+ findAll >>= filterM (\p -> local (pure p) doesFileExist)
+ src/System/FilePath/FilePather/IO.hs view
@@ -0,0 +1,121 @@+{-# OPTIONS_GHC -Wall #-}+{-# LANGUAGE NoImplicitPrelude #-}++module System.FilePath.FilePather.IO(+ readFile+, readFile'+, appendFile+, writeFile+, withFile+, openFile+, withBinaryFile+, openBinaryFile+, openTempFile+, openBinaryTempFile+, openTempFileWithDefaultPermissions+, openBinaryTempFileWithDefaultPermissions+) where++import Control.Exception ( Exception )+import Data.String ( String )+import System.FilePath(FilePath)+import System.FilePath.FilePather.ReadFilePath+ ( ReadFilePathT, tryReadFilePath )+import qualified System.IO as I+ ( appendFile,+ readFile,+ writeFile,+ openBinaryFile,+ openFile,+ openBinaryTempFile,+ openBinaryTempFileWithDefaultPermissions,+ openTempFile,+ openTempFileWithDefaultPermissions,+ readFile',+ withBinaryFile,+ withFile )+import System.IO(IO, IOMode, Handle)++readFile ::+ Exception e =>+ ReadFilePathT e IO String+readFile =+ tryReadFilePath I.readFile++readFile' ::+ Exception e =>+ ReadFilePathT e IO String+readFile' =+ tryReadFilePath I.readFile'++appendFile ::+ Exception e =>+ String+ -> ReadFilePathT e IO ()+appendFile s =+ tryReadFilePath (`I.appendFile` s)++writeFile ::+ Exception e =>+ String+ -> ReadFilePathT e IO ()+writeFile s =+ tryReadFilePath (`I.writeFile` s)++withFile ::+ Exception e =>+ IOMode+ -> (Handle -> IO r)+ -> ReadFilePathT e IO r+withFile mode k =+ tryReadFilePath (\p -> I.withFile p mode k)++openFile ::+ Exception e =>+ IOMode+ -> ReadFilePathT e IO Handle+openFile mode =+ tryReadFilePath (`I.openFile` mode)++withBinaryFile ::+ Exception e =>+ IOMode+ -> (Handle -> IO r)+ -> ReadFilePathT e IO r+withBinaryFile mode k =+ tryReadFilePath (\p -> I.withBinaryFile p mode k)++openBinaryFile ::+ Exception e =>+ IOMode+ -> ReadFilePathT e IO Handle+openBinaryFile mode =+ tryReadFilePath (`I.openBinaryFile` mode)++openTempFile ::+ Exception e =>+ String+ -> ReadFilePathT e IO (FilePath, Handle)+openTempFile s =+ tryReadFilePath (`I.openTempFile` s)++openBinaryTempFile ::+ Exception e =>+ String+ -> ReadFilePathT e IO (FilePath, Handle)+openBinaryTempFile s =+ tryReadFilePath (`I.openBinaryTempFile` s)++openTempFileWithDefaultPermissions ::+ Exception e =>+ String+ -> ReadFilePathT e IO (FilePath, Handle)+openTempFileWithDefaultPermissions s =+ tryReadFilePath (`I.openTempFileWithDefaultPermissions` s)++openBinaryTempFileWithDefaultPermissions ::+ Exception e =>+ String+ -> ReadFilePathT e IO (FilePath, Handle)+openBinaryTempFileWithDefaultPermissions s =+ tryReadFilePath (`I.openBinaryTempFileWithDefaultPermissions` s)
src/System/FilePath/FilePather/Posix.hs view
@@ -1,7 +1,7 @@ {-# OPTIONS_GHC -Wall #-} {-# LANGUAGE NoImplicitPrelude #-} -module System.FilePath.FilePather.Posix(+module System.FilePath.FilePather.Posix ( splitExtension , takeExtension , replaceExtension@@ -24,7 +24,6 @@ , replaceDirectory , combine , splitPath-, joinPath , splitDirectories , splitDrive , joinDrive@@ -47,254 +46,256 @@ import Control.Applicative ( Applicative ) import Control.Category((.))-import Control.Lens ( (#) ) import Data.String( String ) import Data.Bool( Bool ) import Data.Maybe ( Maybe ) import qualified System.FilePath.Posix as FP-import System.FilePath.Posix as SFP(FilePath, pathSeparator, pathSeparators, isPathSeparator, extSeparator, isExtSeparator, splitSearchPath, (-<.>), (</>))-import System.FilePath.FilePather.ToFilePath- ( ToFilePath, toFilePath )+import System.FilePath.Posix as SFP(FilePath) import System.FilePath.FilePather.ReadFilePath ( ReadFilePathT, liftReadFilePath ) splitExtension :: Applicative f =>- ReadFilePathT f (String, String)+ ReadFilePathT e f (String, String) splitExtension = liftReadFilePath FP.splitExtension takeExtension :: Applicative f =>- ReadFilePathT f String+ ReadFilePathT e f String takeExtension = liftReadFilePath FP.takeExtension replaceExtension :: Applicative f =>- ReadFilePathT f (String -> FilePath)+ String+ -> ReadFilePathT e f FilePath replaceExtension =- liftReadFilePath FP.replaceExtension+ liftReadFilePath . FP.replaceExtension dropExtension :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath dropExtension = liftReadFilePath FP.dropExtensions addExtension :: Applicative f =>- ReadFilePathT f (String -> FilePath)+ String+ -> ReadFilePathT e f FilePath addExtension =- liftReadFilePath FP.addExtension+ liftReadFilePath . FP.addExtension hasExtension :: Applicative f =>- ReadFilePathT f Bool+ ReadFilePathT e f Bool hasExtension = liftReadFilePath FP.hasExtension splitExtensions :: Applicative f =>- ReadFilePathT f (FilePath, String)+ ReadFilePathT e f (FilePath, String) splitExtensions = liftReadFilePath FP.splitExtensions dropExtensions :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath dropExtensions = liftReadFilePath FP.dropExtensions takeExtensions :: Applicative f =>- ReadFilePathT f String+ ReadFilePathT e f String takeExtensions = liftReadFilePath FP.takeExtensions replaceExtensions :: Applicative f =>- ReadFilePathT f (String -> FilePath)+ String+ -> ReadFilePathT e f FilePath replaceExtensions =- liftReadFilePath FP.replaceExtensions+ liftReadFilePath . FP.replaceExtensions isExtensionOf :: Applicative f => String- -> ReadFilePathT f Bool+ -> ReadFilePathT e f Bool isExtensionOf = liftReadFilePath . FP.isExtensionOf stripExtension :: Applicative f => String- -> ReadFilePathT f (Maybe FilePath)+ -> ReadFilePathT e f (Maybe FilePath) stripExtension = liftReadFilePath . FP.stripExtension splitFileName :: Applicative f =>- ReadFilePathT f (String, String)+ ReadFilePathT e f (String, String) splitFileName = liftReadFilePath FP.splitFileName takeFileName :: Applicative f =>- ReadFilePathT f String+ ReadFilePathT e f String takeFileName = liftReadFilePath FP.takeFileName replaceFileName :: Applicative f =>- ReadFilePathT f (String -> FilePath)+ String+ -> ReadFilePathT e f FilePath replaceFileName =- liftReadFilePath FP.replaceFileName+ liftReadFilePath . FP.replaceFileName dropFileName :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath dropFileName = liftReadFilePath FP.dropFileName takeBaseName :: Applicative f =>- ReadFilePathT f String+ ReadFilePathT e f String takeBaseName = liftReadFilePath FP.takeBaseName replaceBaseName :: Applicative f =>- ReadFilePathT f (String -> FilePath)+ String ->+ ReadFilePathT e f FilePath replaceBaseName =- liftReadFilePath FP.replaceBaseName+ liftReadFilePath . FP.replaceBaseName takeDirectory :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath takeDirectory = liftReadFilePath FP.takeDirectory replaceDirectory :: Applicative f =>- ReadFilePathT f (String -> FilePath)+ String ->+ ReadFilePathT e f FilePath replaceDirectory =- liftReadFilePath FP.replaceDirectory+ liftReadFilePath . FP.replaceDirectory combine :: Applicative f =>- ReadFilePathT f (FilePath -> FilePath)+ FilePath+ -> ReadFilePathT e f FilePath combine =- liftReadFilePath FP.combine+ liftReadFilePath . FP.combine splitPath :: Applicative f =>- ReadFilePathT f [FilePath]+ ReadFilePathT e f [FilePath] splitPath = liftReadFilePath FP.splitPath -joinPath ::- ToFilePath [FilePath]-joinPath =- toFilePath # FP.joinPath- splitDirectories :: Applicative f =>- ReadFilePathT f [FilePath]+ ReadFilePathT e f [FilePath] splitDirectories = liftReadFilePath FP.splitDirectories splitDrive :: Applicative f =>- ReadFilePathT f (FilePath, FilePath)+ ReadFilePathT e f (FilePath, FilePath) splitDrive = liftReadFilePath FP.splitDrive joinDrive :: Applicative f =>- ReadFilePathT f (FilePath -> FilePath)+ FilePath+ -> ReadFilePathT e f FilePath joinDrive =- liftReadFilePath FP.joinDrive+ liftReadFilePath . FP.joinDrive takeDrive :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath takeDrive = liftReadFilePath FP.takeDrive hasDrive :: Applicative f =>- ReadFilePathT f Bool+ ReadFilePathT e f Bool hasDrive = liftReadFilePath FP.hasDrive dropDrive :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath dropDrive = liftReadFilePath FP.dropDrive isDrive :: Applicative f =>- ReadFilePathT f Bool+ ReadFilePathT e f Bool isDrive = liftReadFilePath FP.isDrive hasTrailingPathSeparator :: Applicative f =>- ReadFilePathT f Bool+ ReadFilePathT e f Bool hasTrailingPathSeparator = liftReadFilePath FP.hasTrailingPathSeparator addTrailingPathSeparator :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath addTrailingPathSeparator = liftReadFilePath FP.addTrailingPathSeparator dropTrailingPathSeparator :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath dropTrailingPathSeparator = liftReadFilePath FP.dropTrailingPathSeparator normalise :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath normalise = liftReadFilePath FP.normalise equalFilePath :: Applicative f =>- ReadFilePathT f (FilePath -> Bool)+ FilePath+ -> ReadFilePathT e f Bool equalFilePath =- liftReadFilePath FP.equalFilePath+ liftReadFilePath . FP.equalFilePath makeRelative :: Applicative f =>- ReadFilePathT f (FilePath -> FilePath)+ FilePath+ -> ReadFilePathT e f FilePath makeRelative =- liftReadFilePath FP.makeRelative+ liftReadFilePath . FP.makeRelative isRelative :: Applicative f =>- ReadFilePathT f Bool+ ReadFilePathT e f Bool isRelative = liftReadFilePath FP.isRelative isAbsolute :: Applicative f =>- ReadFilePathT f Bool+ ReadFilePathT e f Bool isAbsolute = liftReadFilePath FP.isAbsolute isValid :: Applicative f =>- ReadFilePathT f Bool+ ReadFilePathT e f Bool isValid = liftReadFilePath FP.isValid makeValid :: Applicative f =>- ReadFilePathT f FilePath+ ReadFilePathT e f FilePath makeValid = liftReadFilePath FP.makeValid
src/System/FilePath/FilePather/ReadFilePath.hs view
@@ -1,28 +1,38 @@ {-# OPTIONS_GHC -Wall #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE NoImplicitPrelude #-} module System.FilePath.FilePather.ReadFilePath(- ReadFilePathT(..)-, ReadFilePath+ ReadFilePathT , ReadFilePathT1 , ReadFilePath1 , readFilePath-, hoistReadFilePath+, swapReadFilePath+, pureReadFilePath , liftReadFilePath+, successReadFilePath+, errorReadFilePath+, maybeReadFilePath+, tryReadFilePath ) where -import Control.Applicative- ( Applicative(liftA2, (<*>), pure), Alternative((<|>), empty) )-import Control.Category((.))+import Control.Applicative ( Applicative((<*>), pure) )+import Control.Category ( Category((.)) )+import Control.Exception ( try, Exception ) import Control.Lens- ( iso, Iso, Rewrapped, Wrapped(Unwrapped, _Wrapped'), view, _Wrapped, ( # ) )+ ( view,+ iso,+ swapped,+ _Wrapped,+ Field1(_1),+ Iso,+ Rewrapped,+ Wrapped(..) ) import Control.Monad- ( Monad((>>=), return), Functor(fmap), MonadPlus(mplus, mzero) )+ ( join, Monad(return, (>>=)) ) import Control.Monad.Cont.Class ( MonadCont(callCC) ) import Control.Monad.Error.Class ( MonadError(throwError, catchError) ) import Control.Monad.Fail ( MonadFail(fail) )@@ -34,138 +44,192 @@ import Control.Monad.Trans.Class(MonadTrans(lift)) import Control.Monad.Writer.Class ( MonadWriter(pass, tell, writer, listen) ) import Control.Monad.Zip ( MonadZip(mzipWith) )-import Data.Functor.Apply ( Apply(liftF2, (<.>)) )-import Data.Functor.Alt ( Alt((<!>)) )+import Data.Either ( Either(..), either )+import Data.Functor ( Functor(fmap) )+import Data.Functor.Alt ( Apply((<.>)), Alt((<!>)) ) import Data.Functor.Bind ( Bind((>>-)) )-import Data.Functor.Identity(Identity(Identity, runIdentity))-import Data.Monoid(Monoid(mappend, mempty))-import Data.Semigroup(Semigroup((<>)))-import System.FilePath(FilePath)+import Data.Functor.Identity( Identity(..) )+import Data.Maybe ( Maybe, maybe )+import Data.Monoid ( Monoid(mempty, mappend) )+import Data.Semigroup ( Semigroup((<>)) )+import System.FilePath ( FilePath )+import System.IO ( IO ) -newtype ReadFilePathT f a =- ReadFilePathT (FilePath -> f a)+newtype ReadFilePathT e f a =+ ReadFilePathT (FilePath -> f (Either e a)) -instance ReadFilePathT f a ~ t =>- Rewrapped (ReadFilePathT f' a') t+instance ReadFilePathT e f a ~ t =>+ Rewrapped (ReadFilePathT e' f' a') t -instance Wrapped (ReadFilePathT f a) where- type Unwrapped (ReadFilePathT f a) =+instance Wrapped (ReadFilePathT e f a) where+ type Unwrapped (ReadFilePathT e f a) = FilePath- -> f a+ -> f (Either e a) _Wrapped' = iso (\(ReadFilePathT x) -> x) ReadFilePathT {-# INLINE _Wrapped' #-} -type ReadFilePath a =- ReadFilePathT Identity a+type ReadFilePath e a =+ ReadFilePathT e Identity a -type ReadFilePathT1 f =- ReadFilePathT f ()+type ReadFilePathT1 e f =+ ReadFilePathT e f () -type ReadFilePath1 f =- ReadFilePath ()+type ReadFilePath1 e f =+ ReadFilePath e () readFilePath :: Iso- (ReadFilePath a)- (ReadFilePath a')- (FilePath -> a)- (FilePath -> a')+ (ReadFilePath e a)+ (ReadFilePath e' a')+ (FilePath -> Either e a)+ (FilePath -> Either e' a') readFilePath = iso (\(ReadFilePathT x) -> runIdentity . x) (\p -> ReadFilePathT (Identity . p)) {-# INLINE readFilePath #-} -instance (Apply f, Semigroup a) => Semigroup (ReadFilePathT f a) where- ReadFilePathT a <> ReadFilePathT b =- ReadFilePathT (\p -> liftF2 (<>) (a p) (b p))+swapReadFilePath ::+ Functor f =>+ Iso+ (ReadFilePathT e f a)+ (ReadFilePathT e' f a')+ (ReadFilePathT a f e)+ (ReadFilePathT a' f e')+swapReadFilePath =+ iso+ (\r -> ReadFilePathT (fmap (view swapped) . view _Wrapped r))+ (\r -> ReadFilePathT (fmap (view swapped) . view _Wrapped r))+{-# INLINE swapReadFilePath #-}++pureReadFilePath ::+ Applicative f =>+ ReadFilePath e a+ -> ReadFilePathT e f a+pureReadFilePath =+ hoist (pure . runIdentity)+{-# INLINE pureReadFilePath #-}++liftReadFilePath ::+ Applicative f =>+ (FilePath -> a)+ -> ReadFilePathT e f a+liftReadFilePath =+ pureReadFilePath . reader+{-# INLINE liftReadFilePath #-}++successReadFilePath ::+ Functor f =>+ (FilePath -> f a)+ -> ReadFilePathT e f a+successReadFilePath k =+ ReadFilePathT (fmap Right . k)+{-# INLINE successReadFilePath #-}++errorReadFilePath ::+ Functor f =>+ (FilePath -> f e)+ -> ReadFilePathT e f a+errorReadFilePath k =+ ReadFilePathT (fmap Left . k)+{-# INLINE errorReadFilePath #-}++maybeReadFilePath ::+ Functor f =>+ (FilePath -> f (Maybe a))+ -> ReadFilePathT () f a+maybeReadFilePath k =+ ReadFilePathT (fmap (maybe (Left ()) Right) . k)+{-# INLINE maybeReadFilePath #-}++tryReadFilePath ::+ Exception e =>+ (FilePath -> IO a)+ -> ReadFilePathT e IO a+tryReadFilePath k =+ ReadFilePathT (try . k)+{-# INLINE tryReadFilePath #-}++instance (Monad f, Semigroup a) => Semigroup (ReadFilePathT e f a) where+ ReadFilePathT x <> ReadFilePathT y =+ ReadFilePathT (\p -> x p >>= either (pure . Left) (\a -> fmap (fmap (a <>)) (y p))) {-# INLINE (<>) #-} -instance (Apply f, Applicative f, Monoid a) => Monoid (ReadFilePathT f a) where- ReadFilePathT a `mappend` ReadFilePathT b =- ReadFilePathT (\p -> liftA2 mappend (a p) (b p))+instance (Monad f, Monoid a) => Monoid (ReadFilePathT e f a) where+ mappend =+ (<>) {-# INLINE mappend #-} mempty =- ReadFilePathT (pure (pure mempty))+ ReadFilePathT (pure (pure (pure mempty))) {-# INLINE mempty #-} -instance Functor f => Functor (ReadFilePathT f) where+instance Functor f => Functor (ReadFilePathT e f) where fmap f (ReadFilePathT x) =- ReadFilePathT (fmap (fmap f) x)+ ReadFilePathT (fmap (fmap (fmap f)) x) {-# INLINE fmap #-} -instance Apply f => Apply (ReadFilePathT f) where- ReadFilePathT f <.> ReadFilePathT a =- ReadFilePathT (\p -> f p <.> a p)+instance Monad f => Apply (ReadFilePathT e f) where+ ReadFilePathT f <.> ReadFilePathT k =+ ReadFilePathT (\p -> f p >>= either (pure . Left) (\a -> fmap (fmap a) (k p))) {-# INLINE (<.>) #-} -instance Bind f => Bind (ReadFilePathT f) where+instance Monad f => Bind (ReadFilePathT e f) where ReadFilePathT f >>- g =- ReadFilePathT (\p -> f p >>- \a -> view _Wrapped (g a) p)+ ReadFilePathT (\p -> f p >>= either (pure . Left) (\a -> view _Wrapped (g a) p)) {-# INLINE (>>-) #-} -instance Applicative f => Applicative (ReadFilePathT f) where- ReadFilePathT f <*> ReadFilePathT a =- ReadFilePathT (\p -> f p <*> a p)- {-# INLINE (<*>) #-}+instance Monad f => Applicative (ReadFilePathT e f) where+ (<*>) =+ (<.>) pure =- ReadFilePathT . pure . pure- {-# INLINE pure #-}+ ReadFilePathT . pure . pure . pure -instance Alt f => Alt (ReadFilePathT f) where+instance Monad f => Alt (ReadFilePathT e f) where ReadFilePathT a <!> ReadFilePathT b =- ReadFilePathT (\p -> a p <!> b p)+ ReadFilePathT (\p -> a p >>= either (pure (b p)) (pure . pure)) {-# INLINE (<!>) #-} -instance Alternative f => Alternative (ReadFilePathT f) where- ReadFilePathT a <|> ReadFilePathT b =- ReadFilePathT (\p -> a p <|> b p)- {-# INLINE (<|>) #-}- empty =- ReadFilePathT (pure empty)- {-# INLINE empty #-}--instance Monad f => Monad (ReadFilePathT f) where- ReadFilePathT f >>= g =- ReadFilePathT (\p -> f p >>= \a -> view _Wrapped (g a) p)+instance Monad f => Monad (ReadFilePathT e f) where+ (>>=) =+ (>>-) {-# INLINE (>>=) #-} return =- ReadFilePathT . return . return+ pure {-# INLINE return #-} -instance MonadTrans ReadFilePathT where+instance MonadTrans (ReadFilePathT e) where lift =- ReadFilePathT . pure+ ReadFilePathT . pure . fmap pure {-# INLINE lift #-} -instance MonadIO f => MonadIO (ReadFilePathT f) where+instance MonadIO f => MonadIO (ReadFilePathT e f) where liftIO =- ReadFilePathT . pure . liftIO+ ReadFilePathT . pure . liftIO . fmap pure {-# INLINE liftIO #-} -instance MFunctor ReadFilePathT where+instance MFunctor (ReadFilePathT e) where hoist k (ReadFilePathT f) = ReadFilePathT (k .f) {-# INLINE hoist #-} -instance MMonad ReadFilePathT where+instance MMonad (ReadFilePathT e) where embed k (ReadFilePathT f) =- ReadFilePathT (\p -> view _Wrapped (k (f p)) p)+ ReadFilePathT (\p -> fmap join (view _Wrapped (k (f p)) p)) {-# INLINE embed #-} -instance Monad f => MonadReader FilePath (ReadFilePathT f) where+instance Monad f => MonadReader FilePath (ReadFilePathT e f) where ask =- ReadFilePathT pure+ ReadFilePathT (pure . pure) {-# INLINE ask #-} local k (ReadFilePathT f) = ReadFilePathT (f . k) {-# INLINE local #-} reader k =- ReadFilePathT (pure . k)+ ReadFilePathT (pure . pure . k) {-# INLINE reader #-} -instance MonadState FilePath f => MonadState FilePath (ReadFilePathT f) where+instance MonadState FilePath f => MonadState FilePath (ReadFilePathT e f) where state = lift . state {-# INLINE state #-}@@ -176,7 +240,7 @@ lift . put {-# INLINE put #-} -instance MonadWriter FilePath f => MonadWriter FilePath (ReadFilePathT f) where+instance MonadWriter FilePath f => MonadWriter FilePath (ReadFilePathT e f) where writer = lift . writer {-# INLINE writer #-}@@ -184,58 +248,36 @@ lift . tell {-# INLINE tell #-} listen (ReadFilePathT f) =- ReadFilePathT (listen . f)+ ReadFilePathT (\p -> fmap (fmap (\a -> (a, p))) (f p)) {-# INLINE listen #-} pass (ReadFilePathT f) =- ReadFilePathT (pass . f)+ ReadFilePathT (fmap (fmap (view _1)) . f) {-# INLINE pass #-} -instance MonadFail f => MonadFail (ReadFilePathT f) where+instance MonadFail f => MonadFail (ReadFilePathT e f) where fail = lift . fail {-# INLINE fail #-} -instance MonadFix f => MonadFix (ReadFilePathT f) where+instance MonadFix f => MonadFix (ReadFilePathT e f) where mfix f =- ReadFilePathT (\p -> mfix (\a -> view _Wrapped (f a) p))+ ReadFilePathT (\p -> mfix (either (pure . Left) (\a -> view _Wrapped (f a) p))) {-# INLINE mfix #-} -instance MonadZip f => MonadZip (ReadFilePathT f) where+instance MonadZip f => MonadZip (ReadFilePathT e f) where mzipWith f (ReadFilePathT m) (ReadFilePathT n) =- ReadFilePathT (\a -> mzipWith f (m a) (n a))+ ReadFilePathT (\p -> m p >>= either (pure . Left) (\a -> fmap (fmap (f a)) (n p))) {-# INLINE mzipWith #-} -instance MonadCont f => MonadCont (ReadFilePathT f) where+instance MonadCont f => MonadCont (ReadFilePathT e f) where callCC p =- ReadFilePathT (\r -> callCC (\c -> view _Wrapped (p (ReadFilePathT . pure . c)) r))+ ReadFilePathT (\r -> callCC (\c -> view _Wrapped (p (ReadFilePathT . pure . c . pure)) r)) {-# INLINE callCC #-} -instance MonadError e f => MonadError e (ReadFilePathT f) where+instance MonadError e f => MonadError e (ReadFilePathT e f) where throwError = lift . throwError {-# INLINE throwError #-} catchError (ReadFilePathT f) g = ReadFilePathT (\ r -> catchError (f r) (\ e -> view _Wrapped (g e) r)) {-# INLINE catchError #-}--instance MonadPlus f => MonadPlus (ReadFilePathT f) where- mzero =- lift mzero- {-# INLINE mzero #-}- ReadFilePathT a `mplus` ReadFilePathT b =- ReadFilePathT (\ r -> a r `mplus` b r)- {-# INLINE mplus #-}--hoistReadFilePath ::- Applicative f =>- ReadFilePath a- -> ReadFilePathT f a-hoistReadFilePath =- hoist (pure . runIdentity)--liftReadFilePath ::- Applicative f =>- (FilePath -> a)- -> ReadFilePathT f a-liftReadFilePath =- hoistReadFilePath . (readFilePath #)
− src/System/FilePath/FilePather/ToFilePath.hs
@@ -1,77 +0,0 @@-{-# OPTIONS_GHC -Wall #-}-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE TypeFamilies #-}--module System.FilePath.FilePather.ToFilePath(- ToFilePathT(..)-, ToFilePath-, toFilePath-, toRead-) where--import Control.Applicative ( Applicative(pure, liftA2) )-import Control.Category ( Category((.)) )-import Control.Lens ( iso, Iso, Wrapped(..) )-import Data.Functor.Contravariant ( Contravariant(contramap) )-import Data.Either ( either )-import Data.Functor.Contravariant.Divisible- ( Decidable(..), Divisible(..) )-import Data.Functor.Identity ( Identity(..) )-import Data.Void ( absurd )-import System.FilePath ( (</>), FilePath )-import System.FilePath.FilePather.ReadFilePath- ( ReadFilePathT(..) )--newtype ToFilePathT f a =- ToFilePathT (a -> f FilePath)--type ToFilePath a =- ToFilePathT Identity a--instance Wrapped (ToFilePathT f a) where- type Unwrapped (ToFilePathT f a) =- a- -> f FilePath- _Wrapped' =- iso (\(ToFilePathT x) -> x) ToFilePathT- {-# INLINE _Wrapped' #-}--instance Contravariant (ToFilePathT f) where- contramap f (ToFilePathT g) =- ToFilePathT (g . f)--instance Applicative f => Divisible (ToFilePathT f) where- divide f (ToFilePathT g) (ToFilePathT h) =- ToFilePathT (\x -> let (b, c) = f x in liftA2 (</>) (g b) (h c))- conquer =- ToFilePathT (pure (pure ""))--instance Applicative f => Decidable (ToFilePathT f) where- choose f (ToFilePathT g) (ToFilePathT h) =- ToFilePathT (either g h . f)- lose f =- ToFilePathT (absurd . f)--toFilePath ::- Iso- (ToFilePath a)- (ToFilePath a')- (a -> FilePath)- (a' -> FilePath)-toFilePath =- iso- (\(ToFilePathT x) -> runIdentity . x)- (\p -> ToFilePathT (Identity . p))-{-# INLINE toFilePath #-}--toRead ::- Iso- (ToFilePathT f FilePath)- (ToFilePathT f' FilePath)- (ReadFilePathT f FilePath)- (ReadFilePathT f' FilePath)-toRead =- iso- (\(ToFilePathT x) -> ReadFilePathT x)- (\(ReadFilePathT x) -> ToFilePathT x)-{-# INLINE toRead #-}