-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | File system data structure and monad transformer. -- -- FileSystem allows you to create a virtual file system. This package -- defines: -- --
-- a ~> b <|> c ~> d
-- = Either a c ~> Either b d { (a ~> b) lifted with Left for Left values.
-- with -{
-- { (c ~> d) lifted with Right for Right values.
--
--
-- Its name comes from the union of <$> and
-- |||.
(<|>) :: ArrowChoice f => f a b -> f c d -> f (Either a c) (Either b d)
-- | This operator is similar to $, but the argument is used twice.
($$) :: (a -> a -> b) -> a -> b
-- | Transforms a simple arrow to the same arrow applied to the two
-- components of a pair.
pairMap :: Arrow f => f a b -> f (a, a) (b, b)
module System.FileSystem.Types
-- | Internal Application: An application from somewhere over itself.
type InApp a = a -> a
-- | A name for a directory.
type DirName = String
-- | A name for a file.
type FileName = String
-- | The content of a file. Stored in a ByteString.
type FileCnt = ByteString
-- | A list-based directory path.
type DirPath = [DirName]
-- | Translation between FilePath and DirPath.
toDirPath :: FilePath -> DirPath
-- | Translation between DirPath and FilePath.
fromDirPath :: DirPath -> FilePath
-- | A file path, composed by the path of the directory which contains it,
-- and its file name.
type FPath = (DirPath, FileName)
-- | Translation between FilePath and FPath.
toFPath :: FilePath -> FPath
-- | Translation between FPath and FilePath.
fromFPath :: FPath -> FilePath
-- | Information about the content of a file.
data FileData
FD :: FileCnt -> ClockTime -> FileData
getCnt :: FileData -> FileCnt
getLmt :: FileData -> ClockTime
-- | An empty file data.
emptyFD :: FileData
-- | A complete file.
data File
File :: FileData -> FileName -> File
getFD :: File -> FileData
getFN :: File -> FileName
-- | File System Element: Each one of the elements in a FileSystem.
type FSE = Either (DirName, FileSystem) File
-- | The file system structure. It stores a directory with files and
-- subdirectories.
newtype FileSystem
Directory :: [FSE] -> FileSystem
dirCnt :: FileSystem -> [FSE]
-- | An empty file system.
emptyFileSystem :: FileSystem
-- | Lift a function over a list of FSE (File System Elements) to a
-- function over FileSystem.
modDirCnt :: InApp [FSE] -> InApp FileSystem
-- | A path to a possible File.
data Path
Path :: DirPath -> Maybe File -> Path
pathList :: Path -> DirPath
pathFile :: Path -> Maybe File
-- | Check if a Path contents a File.
isFilePath :: Path -> Bool
-- | The state of file system computations.
--
-- Currently, a FileSystem structure.
type FSState = FileSystem
-- | Monadic transformer which adds a FSState environment.
newtype FST m a
WrapFST :: StateT FSState m a -> FST m a
unwrapFST :: FST m a -> StateT FSState m a
-- | Run an FST computation, given an initial state.
runFST :: Monad m => FST m a -> FSState -> m (a, FSState)
-- | Application of the FST monad transformer to the Identity
-- monad.
type FS = FST Identity
-- | Just a composition of runIdentity and runFST.
runFS :: FS a -> FSState -> (a, FSState)
instance Functor m => Functor (FST m)
instance Monad m => Monad (FST m)
instance MonadIO m => MonadIO (FST m)
instance MonadTrans FST
instance Show FileSystem
instance Eq File
instance Eq FileData
instance Show File
-- | Low-level operators.
module System.FileSystem.Operators
-- | Operator for addition of new files/directories.
(<:) :: Path -> FileSystem -> FileSystem
-- | Operator for addition of new file system elements (FSE).
(<<:) :: FSE -> FileSystem -> FileSystem
-- | Operator for search a file.
(?:) :: FPath -> FileSystem -> Maybe File
-- | Descension operator. Extract the file system of an immediate
-- subdirectory.
(=:) :: DirName -> FileSystem -> Maybe FileSystem
-- | Substraction operator. Search and remove a file/directory from a file
-- system.
(-:) :: Path -> FileSystem -> FileSystem
-- | Substitution operator. Provisional implementation.
(<-:) :: ([String], [String], Bool) -> FileSystem -> (FileSystem, Bool)
module System.FileSystem.Class
class (Functor m, Monad m) => FSMonad m
getFS :: FSMonad m => m FSState
putFS :: FSMonad m => FSState -> m ()
modifyFS :: FSMonad m => InApp FSState -> m ()
apgetFS :: FSMonad m => (FSState -> a) -> m a
instance FSMonad m => FSMonad (ContT r m)
instance FSMonad m => FSMonad (ListT m)
instance (Error e, FSMonad m) => FSMonad (ErrorT e m)
instance (Monoid w, FSMonad m) => FSMonad (RWST r w s m)
instance FSMonad m => FSMonad (StateT s m)
instance (Monoid w, FSMonad m) => FSMonad (WriterT w m)
instance FSMonad m => FSMonad (ReaderT r m)
instance (Functor m, Monad m) => FSMonad (FST m)
module System.FileSystem.Computations
putPath :: FSMonad m => Path -> m ()
getFl :: (Functor m, FSMonad m) => FPath -> m (Maybe File)
getDirCnt :: (Functor m, FSMonad m) => DirPath -> m (Maybe ([DirName], [FileName]))
checkFExist :: (Functor m, FSMonad m) => (DirPath, FileName) -> m Bool
checkDExist :: (Functor m, FSMonad m) => DirPath -> m Bool
newDir :: FSMonad m => DirPath -> m ()
rmvPath :: FSMonad m => Path -> m ()
rmvDir :: FSMonad m => DirPath -> m ()
rmvFile :: FSMonad m => FPath -> m ()
rnmPath :: (Functor m, FSMonad m) => ([String], [String], Bool) -> m Bool
rnmDir :: (Functor m, FSMonad m) => (DirPath, DirPath) -> m Bool
rnmFile :: (Functor m, FSMonad m) => (FPath, FPath) -> m Bool
-- | Class instances for several types.
module System.FileSystem.Instances
instance Binary FileSystem
instance Binary File
instance Binary FileData
instance Binary ClockTime
instance Monoid FileSystem
module System.FileSystem.Across
buildFileSystem :: [Path] -> FileSystem
fileSystemList :: FileSystem -> [(Either DirName File, FilePath)]
-- | Folding function for FileSystems.
foldFileSystem :: FilePath -> Either (FilePath -> t -> Either DirName File -> t) (FilePath -> Either DirName File -> t -> t) -> t -> FileSystem -> t
-- | An usage of foldFileSystem, folding only Files, ignoring
-- the FilePath where they are.
foldFiles :: Either (t -> File -> t) (File -> t -> t) -> t -> FileSystem -> t
-- | Map a pair of applications (one over DirName, and the other
-- over File) through a FileSystem.
mapFileSystem :: InApp DirName -> InApp File -> InApp FileSystem
module System.FileSystem.IO
-- | Create a File from a FilePath to a "real world" file.
takeFile :: FilePath -> IO File
-- | Create a complete FileSystem from an existing directory.
captureDir :: FilePath -> IO FileSystem
-- | Create a complete FileSystem from the current working
-- directory.
capture :: IO FileSystem
-- | releaseEnd fp c fs write in fp the FileSystem
-- fs, and execute c at the end.
releaseEnd :: FilePath -> IO a -> FileSystem -> IO a
-- | release fp fs write in fp the FileSystem
-- fs.
release :: FilePath -> FileSystem -> IO ()
-- | releaseHere fs write in the current working directory the
-- FileSystem fs.
releaseHere :: FileSystem -> IO ()
module System.FileSystem
-- | Internal Application: An application from somewhere over itself.
type InApp a = a -> a
-- | A name for a directory.
type DirName = String
-- | A name for a file.
type FileName = String
-- | A space-efficient representation of a Word8 vector, supporting many
-- efficient operations. A ByteString contains 8-bit characters
-- only.
--
-- Instances of Eq, Ord, Read, Show, Data, Typeable
data ByteString :: *
-- | A representation of the internal clock time. Clock times may be
-- compared, converted to strings, or converted to an external calendar
-- time CalendarTime for I/O or other manipulations.
data ClockTime :: *
-- | A complete file.
data File
-- | Create an empty file with the given FileName.
emptyFile :: FileName -> File
-- | Build a new file with an initial FileName and content.
newFile :: FileName -> ByteString -> File
-- | Get the name of a File.
getFileName :: File -> FileName
-- | Rename a File with the given FileName.
setFileName :: FileName -> File -> File
-- | Extract the content of a File.
getFileContent :: File -> ByteString
-- | Set the content of a File to the given ByteString.
setFileContent :: ByteString -> File -> File
-- | Get the last modification time of a File.
getModifTime :: File -> ClockTime
-- | Set the last modification time of a File.
setModifTime :: ClockTime -> File -> File
-- | Calculate the size of a File.
fileSize :: File -> Int
-- | The file system structure. It stores a directory with files and
-- subdirectories.
data FileSystem
-- | An empty file system.
emptyFileSystem :: FileSystem
-- | Map a pair of applications (one over DirName, and the other
-- over File) through a FileSystem.
mapFileSystem :: InApp DirName -> InApp File -> InApp FileSystem
-- | Map a function over all the Files of a FileSystem.
mapFiles :: InApp File -> InApp FileSystem
-- | Folding function for FileSystems.
foldFileSystem :: FilePath -> Either (FilePath -> t -> Either DirName File -> t) (FilePath -> Either DirName File -> t -> t) -> t -> FileSystem -> t
-- | An usage of foldFileSystem, folding only Files, ignoring
-- the FilePath where they are.
foldFiles :: Either (t -> File -> t) (File -> t -> t) -> t -> FileSystem -> t
-- | The state of file system computations.
--
-- Currently, a FileSystem structure.
type FSState = FileSystem
-- | Monadic transformer which adds a FSState environment.
data FST m a
-- | Run an FST computation, given an initial state.
runFST :: Monad m => FST m a -> FSState -> m (a, FSState)
-- | Application of the FST monad transformer to the Identity
-- monad.
type FS = FST Identity
-- | Just a composition of runIdentity and runFST.
runFS :: FS a -> FSState -> (a, FSState)
-- | A list-based directory path.
type DirPath = [DirName]
-- | Translation between FilePath and DirPath.
toDirPath :: FilePath -> DirPath
-- | Translation between DirPath and FilePath.
fromDirPath :: DirPath -> FilePath
-- | A file path, composed by the path of the directory which contains it,
-- and its file name.
type FPath = (DirPath, FileName)
-- | Translation between FilePath and FPath.
toFPath :: FilePath -> FPath
-- | Translation between FPath and FilePath.
fromFPath :: FPath -> FilePath
-- | Puts a file in the given directory. It creates the parent directory if
-- missing.
putFileL :: FSMonad m => DirPath -> File -> m ()
putFile :: FSMonad m => FilePath -> File -> m ()
-- | Gets a file from the file system. It returns Nothing if the
-- File is not found.
getFileL :: FSMonad m => FPath -> m (Maybe File)
getFile :: FSMonad m => FilePath -> m (Maybe File)
-- | Modifies a file with the given application. It returns True if
-- the file was found and modified.
modFileL :: FSMonad m => FPath -> InApp File -> m Bool
modFile :: FSMonad m => FilePath -> InApp File -> m Bool
-- | Moves a file. It returns True if the file exists and has been
-- moved.
moveFileL :: FSMonad m => FPath -> FPath -> m Bool
moveFile :: FSMonad m => FilePath -> FilePath -> m Bool
-- | Writes a file. If the files already exists, it is overwritten.
fs_writeFileL :: FSMonad m => FPath -> ByteString -> m ()
fs_writeFile :: FSMonad m => FilePath -> ByteString -> m ()
-- | Reads a file. It returns Nothing if the file can't be found.
fs_readFileL :: FSMonad m => FPath -> m (Maybe ByteString)
fs_readFile :: FSMonad m => FilePath -> m (Maybe ByteString)
-- | Writes a file, changing its last modification time to the current
-- time. If the file already exists, it is overwritten. Note that
-- MonadIO instance is needed.
writeFileTimeL :: (FSMonad m, MonadIO m) => FPath -> ByteString -> m ()
writeFileTime :: (FSMonad m, MonadIO m) => FilePath -> ByteString -> m ()
-- | Returns all directory names and file names located in the given
-- directory. It returns Nothing if the directory does not exist.
fs_getDirectoryContentsL :: FSMonad m => DirPath -> m (Maybe ([DirName], [FileName]))
fs_getDirectoryContents :: FSMonad m => FilePath -> m (Maybe ([DirName], [FileName]))
-- | Checks if a file exists.
fs_doesFileExistL :: FSMonad m => FPath -> m Bool
fs_doesFileExist :: FSMonad m => FilePath -> m Bool
-- | Checks if a directory exists.
fs_doesDirectoryExistL :: FSMonad m => DirPath -> m Bool
fs_doesDirectoryExist :: FSMonad m => FilePath -> m Bool
-- | Creates a new directory. If the directory already exists, it does
-- nothing.
fs_createDirectoryL :: FSMonad m => DirPath -> m ()
fs_createDirectory :: FSMonad m => FilePath -> m ()
-- | Removes a directory, with all its content. If the directory does not
-- exist, it does nothing.
fs_removeDirectoryL :: FSMonad m => DirPath -> m ()
fs_removeDirectory :: FSMonad m => FilePath -> m ()
-- | Removes a file. If the file does not exist, it does nothing.
fs_removeFileL :: FSMonad m => FPath -> m ()
fs_removeFile :: FSMonad m => FilePath -> m ()
-- | Renames a directory. If the directory can't be found, it returns
-- False.
fs_renameDirectoryL :: FSMonad m => DirPath -> DirPath -> m Bool
fs_renameDirectory :: FSMonad m => FilePath -> FilePath -> m Bool
-- | Renames a file. First, you must specify the directory where the file
-- is. If the file can't be found, it returns False.
fs_renameFileL :: FSMonad m => DirPath -> FileName -> FileName -> m Bool
fs_renameFile :: FSMonad m => FilePath -> FileName -> FileName -> m Bool
-- | Copies a file from a location to another. Returns True if the
-- file was found and copied.
fs_copyFileL :: FSMonad m => FPath -> FPath -> m Bool
fs_copyFile :: FSMonad m => FilePath -> FilePath -> m Bool
-- | Gets the last modification time of a file. It returns Nothing
-- if the file doesn't exist.
fs_getModificationTimeL :: FSMonad m => FPath -> m (Maybe ClockTime)
fs_getModificationTime :: FSMonad m => FilePath -> m (Maybe ClockTime)