Safe Haskell | None |
---|---|
Language | GHC2021 |
Effectful.FileSystem.PathWriter.Static
Description
Provides a static effect for the writable portion of System.Directory's interface. For the static interface of the entire System.Directory interface, see https://hackage.haskell.org/package/effectful-2.2.2.0/docs/Effectful-FileSystem.html.
Since: 0.1
Synopsis
- data PathWriter (a :: Type -> Type) b
- createDirectory :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es ()
- createDirectoryIfMissing :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => Bool -> OsPath -> Eff es ()
- removeDirectory :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es ()
- removeDirectoryRecursive :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es ()
- removePathForcibly :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es ()
- renameDirectory :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- setCurrentDirectory :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es ()
- withCurrentDirectory :: forall (es :: [Effect]) a. (HasCallStack, PathWriter :> es) => OsPath -> Eff es a -> Eff es a
- removeFile :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es ()
- renameFile :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- renamePath :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- copyFile :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- copyFileWithMetadata :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- createFileLink :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- createDirectoryLink :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- removeDirectoryLink :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es ()
- setPermissions :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Permissions -> Eff es ()
- copyPermissions :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- setAccessTime :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> UTCTime -> Eff es ()
- setModificationTime :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> UTCTime -> Eff es ()
- runPathWriter :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (PathWriter ': es) a -> Eff es a
- data CopyDirConfig = MkCopyDirConfig {
- overwrite :: !Overwrite
- targetName :: !TargetName
- data Overwrite
- data TargetName
- defaultCopyDirConfig :: CopyDirConfig
- copyDirectoryRecursive :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- copyDirectoryRecursiveConfig :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => CopyDirConfig -> OsPath -> OsPath -> Eff es ()
- copySymbolicLink :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> OsPath -> Eff es ()
- _OverwriteNone :: Prism' Overwrite ()
- _OverwriteDirectories :: Prism' Overwrite ()
- _OverwriteAll :: Prism' Overwrite ()
- _TargetNameSrc :: Prism' TargetName ()
- _TargetNameLiteral :: Prism' TargetName OsPath
- _TargetNameDest :: Prism' TargetName ()
- removeFileIfExists :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es Bool
- removeFileIfExists_ :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es ()
- removeDirectoryIfExists :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es Bool
- removeDirectoryIfExists_ :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es ()
- removeDirectoryRecursiveIfExists :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es Bool
- removeDirectoryRecursiveIfExists_ :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es ()
- removePathForciblyIfExists :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es Bool
- removePathForciblyIfExists_ :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es ()
- removeSymbolicLink :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es ()
- removeSymbolicLinkIfExists :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es Bool
- removeSymbolicLinkIfExists_ :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es ()
- type OsPath = OsString
- data IOException
- data Permissions
- data UTCTime = UTCTime {
- utctDay :: Day
- utctDayTime :: DiffTime
Effect
data PathWriter (a :: Type -> Type) b Source #
Static effect for writing paths.
Since: 0.1
Instances
type DispatchOf PathWriter Source # | |
Defined in Effectful.FileSystem.PathWriter.Static | |
data StaticRep PathWriter Source # | |
Defined in Effectful.FileSystem.PathWriter.Static |
createDirectory :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es () Source #
Lifted createDirectory
.
Since: 0.1
createDirectoryIfMissing :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => Bool -> OsPath -> Eff es () Source #
Lifted createDirectoryIfMissing
.
Since: 0.1
removeDirectory :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es () Source #
Lifted removeDirectory
.
Since: 0.1
removeDirectoryRecursive :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es () Source #
Lifted removeDirectoryRecursive
.
Since: 0.1
removePathForcibly :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es () Source #
Lifted removePathForcibly
.
Since: 0.1
renameDirectory :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es () Source #
Lifted renameDirectory
.
Since: 0.1
setCurrentDirectory :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es () Source #
Lifted setCurrentDirectory
.
Since: 0.1
withCurrentDirectory :: forall (es :: [Effect]) a. (HasCallStack, PathWriter :> es) => OsPath -> Eff es a -> Eff es a Source #
Lifted withCurrentDirectory
.
Since: 0.1
removeFile :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es () Source #
Lifted removeFile
.
Since: 0.1
renameFile :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es () Source #
Lifted renameFile
.
Since: 0.1
renamePath :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es () Source #
Lifted renamePath
.
Since: 0.1
copyFile :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es () Source #
Lifted copyFile
.
Since: 0.1
copyFileWithMetadata :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es () Source #
Lifted copyFileWithMetadata
.
Since: 0.1
createFileLink :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es () Source #
Lifted createFileLink
.
Since: 0.1
createDirectoryLink :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es () Source #
Lifted createDirectoryLink
.
Since: 0.1
removeDirectoryLink :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Eff es () Source #
Lifted removeDirectoryLink
.
Since: 0.1
setPermissions :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> Permissions -> Eff es () Source #
Lifted setPermissions
.
Since: 0.1
copyPermissions :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> OsPath -> Eff es () Source #
Lifted copyPermissions
.
Since: 0.1
setAccessTime :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> UTCTime -> Eff es () Source #
Lifted setAccessTime
.
Since: 0.1
setModificationTime :: forall (es :: [Effect]). (HasCallStack, PathWriter :> es) => OsPath -> UTCTime -> Eff es () Source #
Lifted setModificationTime
.
Since: 0.1
Handlers
runPathWriter :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (PathWriter ': es) a -> Eff es a Source #
Runs an PathWriter
effect in IO.
Since: 0.1
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
NFData Overwrite Source # | Since: 0.1 | ||||
Defined in Effectful.FileSystem.PathWriter.Utils | |||||
Generic Overwrite Source # | |||||
Defined in Effectful.FileSystem.PathWriter.Utils Associated Types
| |||||
Show Overwrite Source # | Since: 0.1 | ||||
Eq Overwrite Source # | Since: 0.1 | ||||
type Rep Overwrite Source # | Since: 0.1 | ||||
Defined in Effectful.FileSystem.PathWriter.Utils type Rep Overwrite = D1 ('MetaData "Overwrite" "Effectful.FileSystem.PathWriter.Utils" "fs-effectful-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
NFData TargetName Source # | Since: 0.1 | ||||
Defined in Effectful.FileSystem.PathWriter.Utils Methods rnf :: TargetName -> () # | |||||
Generic TargetName Source # | |||||
Defined in Effectful.FileSystem.PathWriter.Utils Associated Types
| |||||
Show TargetName Source # | Since: 0.1 | ||||
Defined in Effectful.FileSystem.PathWriter.Utils Methods showsPrec :: Int -> TargetName -> ShowS # show :: TargetName -> String # showList :: [TargetName] -> ShowS # | |||||
Eq TargetName Source # | Since: 0.1 | ||||
Defined in Effectful.FileSystem.PathWriter.Utils | |||||
type Rep TargetName Source # | Since: 0.1 | ||||
Defined in Effectful.FileSystem.PathWriter.Utils type Rep TargetName = D1 ('MetaData "TargetName" "Effectful.FileSystem.PathWriter.Utils" "fs-effectful-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
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | Source |
-> OsPath | Destination |
-> Eff es () |
copyDirectoryRecursiveConfig
with defaultCopyDirConfig
.
Since: 0.1
copyDirectoryRecursiveConfig Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> CopyDirConfig | Config |
-> OsPath | Source |
-> OsPath | Destination |
-> Eff es () |
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:
PathNotFoundException
: ifdest
does not exist.PathFoundException
:OverwriteNone
anddest/<src>
exists.OverwriteDirectories
and somedest/<target>/p
would be overwritten.
Since: 0.1
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | Source |
-> OsPath | Dest |
-> Eff es () |
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
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es Bool |
Calls removeFile
if doesFileExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es () |
Variant of removeFileIfExists
that ignores the return value.
Since: 0.1
removeDirectoryIfExists Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es Bool |
Calls removeDirectory
if doesDirectoryExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
removeDirectoryIfExists_ Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es () |
Variant of removeDirectoryIfExists
that ignores the return value.
Since: 0.1
removeDirectoryRecursiveIfExists Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es Bool |
Calls removeDirectoryRecursive
if doesDirectoryExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
removeDirectoryRecursiveIfExists_ Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es () |
Variant of removeDirectoryRecursiveIfExists
that ignores the return value.
Since: 0.1
removePathForciblyIfExists Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es Bool |
Calls removePathForcibly
if doesPathExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
removePathForciblyIfExists_ Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es () |
Variant of removePathForciblyIfExists
that ignores the return value.
Since: 0.1
Symbolic Links
removeSymbolicLink :: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) => OsPath -> Eff es () Source #
Removes a symbolic link. On Windows, attempts to distinguish file and directory links (Posix makes no distinction).
Since: 0.1
removeSymbolicLinkIfExists Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es Bool |
Calls removeSymbolicLink
if doesSymbolicLinkExist
is True
.
Returns true iff the path is deleted.
Since: 0.1
removeSymbolicLinkIfExists_ Source #
Arguments
:: forall (es :: [Effect]). (HasCallStack, PathReader :> es, PathWriter :> es) | |
=> OsPath | . |
-> Eff es () |
Variant of removeSymbolicLinkIfExists
that ignores the return value.
Since: 0.1
Re-exports
Type representing filenames/pathnames.
This type doesn't add any guarantees over OsString
.
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.Internal.IO.Exception Methods toException :: IOException -> SomeException # fromException :: SomeException -> Maybe IOException # displayException :: IOException -> String # backtraceDesired :: IOException -> Bool # | |
Show IOException | @since base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception Methods showsPrec :: Int -> IOException -> ShowS # show :: IOException -> String # showList :: [IOException] -> ShowS # | |
Eq IOException | @since base-4.1.0.0 |
Defined in GHC.Internal.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
NFData UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
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 # | |
Eq UTCTime | |
Ord UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
ISO8601 UTCTime |
|
Defined in Data.Time.Format.ISO8601 Methods |