Safe Haskell | None |
---|---|
Language | GHC2021 |
Effects.FileSystem.PathWriter
Description
Provides the MonadPathWriter effect.
Since: 0.1
Synopsis
- class Monad m => MonadPathWriter (m :: Type -> Type) where
- createDirectory :: OsPath -> m ()
- createDirectoryIfMissing :: Bool -> OsPath -> m ()
- removeDirectory :: OsPath -> m ()
- removeDirectoryRecursive :: OsPath -> m ()
- removePathForcibly :: OsPath -> m ()
- renameDirectory :: OsPath -> OsPath -> m ()
- setCurrentDirectory :: OsPath -> m ()
- withCurrentDirectory :: HasCallStack => OsPath -> m a -> m a
- removeFile :: OsPath -> m ()
- renameFile :: OsPath -> OsPath -> m ()
- renamePath :: OsPath -> OsPath -> m ()
- copyFile :: OsPath -> OsPath -> m ()
- copyFileWithMetadata :: OsPath -> OsPath -> m ()
- createFileLink :: OsPath -> OsPath -> m ()
- createDirectoryLink :: OsPath -> OsPath -> m ()
- removeDirectoryLink :: OsPath -> m ()
- setPermissions :: OsPath -> Permissions -> m ()
- copyPermissions :: OsPath -> OsPath -> m ()
- setAccessTime :: OsPath -> UTCTime -> m ()
- setModificationTime :: OsPath -> UTCTime -> m ()
- type OsPath = OsString
- data CopyDirConfig = MkCopyDirConfig {
- overwrite :: !Overwrite
- targetName :: !TargetName
- data Overwrite
- data TargetName
- defaultCopyDirConfig :: CopyDirConfig
- copyDirectoryRecursive :: (HasCallStack, MonadIORef m, MonadMask m, MonadPathReader m, MonadPathWriter m) => OsPath -> OsPath -> m ()
- copyDirectoryRecursiveConfig :: (HasCallStack, MonadIORef m, MonadMask m, MonadPathReader m, MonadPathWriter m) => CopyDirConfig -> OsPath -> OsPath -> m ()
- copySymbolicLink :: (HasCallStack, MonadCatch m, MonadPathReader m, MonadPathWriter m) => OsPath -> OsPath -> m ()
- _OverwriteNone :: Prism' Overwrite ()
- _OverwriteDirectories :: Prism' Overwrite ()
- _OverwriteAll :: Prism' Overwrite ()
- _TargetNameSrc :: Prism' TargetName ()
- _TargetNameLiteral :: Prism' TargetName OsPath
- _TargetNameDest :: Prism' TargetName ()
- removeFileIfExists :: (HasCallStack, MonadPathReader m, MonadPathWriter m) => OsPath -> m Bool
- removeFileIfExists_ :: (HasCallStack, MonadPathReader m, MonadPathWriter m) => OsPath -> m ()
- removeDirectoryIfExists :: (HasCallStack, MonadPathReader m, MonadPathWriter m) => OsPath -> m Bool
- removeDirectoryIfExists_ :: (HasCallStack, MonadPathReader m, MonadPathWriter m) => OsPath -> m ()
- removeDirectoryRecursiveIfExists :: (HasCallStack, MonadPathReader m, MonadPathWriter m) => OsPath -> m Bool
- removeDirectoryRecursiveIfExists_ :: (HasCallStack, MonadPathReader m, MonadPathWriter m) => OsPath -> m ()
- removePathForciblyIfExists :: (HasCallStack, MonadPathReader m, MonadPathWriter m) => OsPath -> m Bool
- removePathForciblyIfExists_ :: (HasCallStack, MonadPathReader m, MonadPathWriter m) => OsPath -> m ()
- removeSymbolicLink :: (HasCallStack, MonadCatch m, MonadPathReader m, MonadPathWriter m) => OsPath -> m ()
- removeSymbolicLinkIfExists :: (HasCallStack, MonadCatch m, MonadPathReader m, MonadPathWriter m) => OsPath -> m Bool
- removeSymbolicLinkIfExists_ :: (HasCallStack, MonadCatch m, MonadPathReader m, MonadPathWriter m) => OsPath -> m ()
- data IOException
- data Permissions
- data UTCTime = UTCTime {
- utctDay :: Day
- utctDayTime :: DiffTime
Effect
class Monad m => MonadPathWriter (m :: Type -> Type) where Source #
Represents file-system writer effects.
Since: 0.1
Methods
createDirectory :: OsPath -> m () Source #
Lifted createDirectory
.
Since: 0.1
createDirectoryIfMissing Source #
Lifted createDirectoryIfMissing
.
Since: 0.1
removeDirectory :: OsPath -> m () Source #
Lifted removeDirectory
.
Since: 0.1
removeDirectoryRecursive :: OsPath -> m () Source #
Lifted removeDirectoryRecursive
.
Since: 0.1
removePathForcibly :: OsPath -> m () Source #
Lifted removePathForcibly
.
Since: 0.1
renameDirectory :: OsPath -> OsPath -> m () Source #
Lifted renameDirectory
.
Since: 0.1
setCurrentDirectory :: OsPath -> m () Source #
Lifted setCurrentDirectory
.
Since: 0.1
withCurrentDirectory :: HasCallStack => OsPath -> m a -> m a Source #
Lifted withCurrentDirectory
.
Since: 0.1
removeFile :: OsPath -> m () Source #
Lifted removeFile
.
Since: 0.1
renameFile :: OsPath -> OsPath -> m () Source #
Lifted renameFile
.
Since: 0.1
Lifted renamePath
.
Since: 0.1
Lifted copyFile
.
Since: 0.1
Lifted copyFileWithMetadata
.
Since: 0.1
Lifted createFileLink
.
Since: 0.1
Lifted createDirectoryLink
.
Since: 0.1
removeDirectoryLink :: OsPath -> m () Source #
Lifted removeDirectoryLink
.
Since: 0.1
setPermissions :: OsPath -> Permissions -> m () Source #
Lifted setPermissions
.
Since: 0.1
copyPermissions :: OsPath -> OsPath -> m () Source #
Lifted copyPermissions
.
Since: 0.1
setAccessTime :: OsPath -> UTCTime -> m () Source #
Lifted setAccessTime
.
Since: 0.1
setModificationTime :: OsPath -> UTCTime -> m () Source #
Lifted setModificationTime
.
Since: 0.1
Instances
Type representing filenames/pathnames.
This type doesn't add any guarantees over OsString
.
Copying
Config
data CopyDirConfig Source #
Directory copying config.
Since: 0.1
Constructors
MkCopyDirConfig | |
Fields
|
Instances
Determines file/directory overwrite behavior.
Since: 0.1
Constructors
OverwriteNone | No overwriting allowed. Since: 0.1 |
OverwriteDirectories | Allow overwriting directories. Since: 0.1 |
OverwriteAll | Allow overwriting the target directory and all subpaths. Since: 0.1 |
Instances
Generic Overwrite Source # | |||||
Defined in Effects.FileSystem.PathWriter Associated Types
| |||||
Show Overwrite Source # | Since: 0.1 | ||||
NFData Overwrite Source # | Since: 0.1 | ||||
Defined in Effects.FileSystem.PathWriter | |||||
Eq Overwrite Source # | Since: 0.1 | ||||
type Rep Overwrite Source # | Since: 0.1 | ||||
Defined in Effects.FileSystem.PathWriter type Rep Overwrite = D1 ('MetaData "Overwrite" "Effects.FileSystem.PathWriter" "effects-fs-0.1-inplace" 'False) (C1 ('MetaCons "OverwriteNone" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OverwriteDirectories" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OverwriteAll" 'PrefixI 'False) (U1 :: Type -> Type))) |
data TargetName Source #
Determines how to name the target.
Since: 0.1
Constructors
TargetNameSrc | Uses the src dir as the dest name i.e. Since: 0.1 |
TargetNameLiteral !OsPath | Uses the given literal as the dest name i.e. Since: 0.1 |
TargetNameDest | Uses dest itself as the target i.e. Since: 0.1 |
Instances
Generic TargetName Source # | |||||
Defined in Effects.FileSystem.PathWriter Associated Types
| |||||
Show TargetName Source # | Since: 0.1 | ||||
Defined in Effects.FileSystem.PathWriter Methods showsPrec :: Int -> TargetName -> ShowS # show :: TargetName -> String # showList :: [TargetName] -> ShowS # | |||||
NFData TargetName Source # | Since: 0.1 | ||||
Defined in Effects.FileSystem.PathWriter Methods rnf :: TargetName -> () # | |||||
Eq TargetName Source # | Since: 0.1 | ||||
Defined in Effects.FileSystem.PathWriter | |||||
type Rep TargetName Source # | Since: 0.1 | ||||
Defined in Effects.FileSystem.PathWriter type Rep TargetName = D1 ('MetaData "TargetName" "Effects.FileSystem.PathWriter" "effects-fs-0.1-inplace" 'False) (C1 ('MetaCons "TargetNameSrc" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TargetNameLiteral" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OsPath)) :+: C1 ('MetaCons "TargetNameDest" 'PrefixI 'False) (U1 :: Type -> Type))) |
defaultCopyDirConfig :: CopyDirConfig Source #
Default config for copying directories.
>>>
defaultCopyDirConfig
MkCopyDirConfig {overwrite = OverwriteNone, destName = TargetNameSrc}
Since: 0.1
Functions
copyDirectoryRecursive Source #
Arguments
:: (HasCallStack, MonadIORef m, MonadMask m, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | Source |
-> OsPath | Destination |
-> m () |
copyDirectoryRecursiveConfig
with defaultCopyDirConfig
.
Since: 0.1
copyDirectoryRecursiveConfig Source #
Arguments
:: (HasCallStack, MonadIORef m, MonadMask m, MonadPathReader m, MonadPathWriter m) | |
=> CopyDirConfig | Config |
-> OsPath | Source |
-> OsPath | Destination |
-> m () |
copyDirectoryRecursiveConfig cfg src dest
copies the src
and its
contents into dest
e.g.
copyDirectoryRecursiveConfig cfg "path/to/foo" "path/to/bar"
will create path/to/bar/foo
, path/to/bar/<target>
, or copy
foo
's contents directly into bar
, depending on the value of
targetName
.
The atomicity semantics are as follows:
OverwriteNone
: If an error is encountered, we roll back the successful writes by deleting the entiredest/<target>
.OverwriteDirectories
: If an error is encountered, we attempt to delete all successfully written paths/directories. Because these deletes are performed sequentially, we cannot guarantee all are removed before the process is interrupted.OverwriteAll
: Same asOverwriteDirectories
, except paths that were overwritten are not restored. That is, if a pathdest/<src>/p
is overwritten and an error later encountered,p
is not restored.
Throws:
IOException
: ifdest
does not exist or one of:OverwriteNone
anddest/<src>
exists.OverwriteDirectories
and somedest/<target>/p
would be overwritten.
Since: 0.1
Arguments
:: (HasCallStack, MonadCatch m, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | Source |
-> OsPath | Dest |
-> m () |
Copies the symbolic link without traversing the link i.e. copy the
link itself. Does not throw an exception if the target does exist.
Throws an IOException
if the path is not a symbolic link.
Windows: We have to distinguish between file and directory links (Posix makes no such distinction). If the target does not exist or is not considered a directory (e.g. it could also be a link), we fall back to creating a file link.
Since: 0.1
Optics
_OverwriteNone :: Prism' Overwrite () Source #
Since: 0.1
_OverwriteDirectories :: Prism' Overwrite () Source #
Since: 0.1
_OverwriteAll :: Prism' Overwrite () Source #
Since: 0.1
_TargetNameSrc :: Prism' TargetName () Source #
Since: 0.1
_TargetNameLiteral :: Prism' TargetName OsPath Source #
Since: 0.1
_TargetNameDest :: Prism' TargetName () Source #
Since: 0.1
Removing
The removeXIfExists
functions should be understood as helper combinators
for the obvious doesXExist -> removeX
pattern. They should not be
understood as a total "delete arbitrary path if it exists" pattern.
For instance, doesDirectoryExist
will return true if the target of a
symbolic link is a directory, yet removeDirectory
will throw an exception.
Thus these functions should only be used when the type (file, dir, symlink)
of a (possibly non-extant) path is known.
Arguments
:: (HasCallStack, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m Bool |
Calls removeFile
if doesFileExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
Arguments
:: (HasCallStack, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m () |
Variant of removeFileIfExists
that ignores the return value.
Since: 0.1
removeDirectoryIfExists Source #
Arguments
:: (HasCallStack, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m Bool |
Calls removeDirectory
if doesDirectoryExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
removeDirectoryIfExists_ Source #
Arguments
:: (HasCallStack, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m () |
Variant of removeDirectoryIfExists
that ignores the return value.
Since: 0.1
removeDirectoryRecursiveIfExists Source #
Arguments
:: (HasCallStack, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m Bool |
Calls removeDirectoryRecursive
if doesDirectoryExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
removeDirectoryRecursiveIfExists_ Source #
Arguments
:: (HasCallStack, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m () |
Variant of removeDirectoryRecursiveIfExists
that ignores the return value.
Since: 0.1
removePathForciblyIfExists Source #
Arguments
:: (HasCallStack, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m Bool |
Calls removePathForcibly
if doesPathExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
removePathForciblyIfExists_ Source #
Arguments
:: (HasCallStack, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m () |
Variant of removePathForciblyIfExists
that ignores the return value.
Since: 0.1
Symbolic Links
Arguments
:: (HasCallStack, MonadCatch m, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m () |
Removes a symbolic link. On Windows, attempts to distinguish file and directory links (Posix makes no distinction).
Since: 0.1
removeSymbolicLinkIfExists Source #
Arguments
:: (HasCallStack, MonadCatch m, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m Bool |
Calls removeSymbolicLink
if doesSymbolicLinkExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
removeSymbolicLinkIfExists_ Source #
Arguments
:: (HasCallStack, MonadCatch m, MonadPathReader m, MonadPathWriter m) | |
=> OsPath | . |
-> m () |
Variant of removeSymbolicLinkIfExists
that ignores the return value.
Since: 0.1
Reexports
data IOException #
Exceptions that occur in the IO
monad.
An IOException
records a more specific error type, a descriptive
string and maybe the handle that was used when the error was
flagged.
Instances
Exception IOException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception Methods toException :: IOException -> SomeException # fromException :: SomeException -> Maybe IOException # displayException :: IOException -> String # | |
Show IOException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> IOException -> ShowS # show :: IOException -> String # showList :: [IOException] -> ShowS # | |
Eq IOException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception |
data Permissions #
Instances
Read Permissions | |
Defined in System.Directory.Internal.Common Methods readsPrec :: Int -> ReadS Permissions # readList :: ReadS [Permissions] # readPrec :: ReadPrec Permissions # readListPrec :: ReadPrec [Permissions] # | |
Show Permissions | |
Defined in System.Directory.Internal.Common Methods showsPrec :: Int -> Permissions -> ShowS # show :: Permissions -> String # showList :: [Permissions] -> ShowS # | |
Eq Permissions | |
Defined in System.Directory.Internal.Common | |
Ord Permissions | |
Defined in System.Directory.Internal.Common Methods compare :: Permissions -> Permissions -> Ordering # (<) :: Permissions -> Permissions -> Bool # (<=) :: Permissions -> Permissions -> Bool # (>) :: Permissions -> Permissions -> Bool # (>=) :: Permissions -> Permissions -> Bool # max :: Permissions -> Permissions -> Permissions # min :: Permissions -> Permissions -> Permissions # |
This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.
Constructors
UTCTime | |
Fields
|
Instances
Data UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UTCTime -> c UTCTime # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UTCTime # toConstr :: UTCTime -> Constr # dataTypeOf :: UTCTime -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UTCTime) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UTCTime) # gmapT :: (forall b. Data b => b -> b) -> UTCTime -> UTCTime # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQ :: (forall d. Data d => d -> u) -> UTCTime -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UTCTime -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # | |
NFData UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
Eq UTCTime | |
Ord UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
ISO8601 UTCTime |
|
Defined in Data.Time.Format.ISO8601 Methods |