hydra-kernel-0.18.1: src/main/haskell/Hydra/Core/Lib/Files.hs
-- Note: this is an automatically generated file. Do not edit.
-- | Primitives in the hydra.core.lib.files module.
module Hydra.Core.Lib.Files where
import qualified Hydra.Core.Error.File as ErrorFile
import qualified Hydra.Core.File as File
import qualified Hydra.Core.Model as Model
import qualified Hydra.Core.Packaging as Packaging
import qualified Hydra.Core.Typing as Typing
import Prelude hiding (Enum, Ordering, decodeFloat, encodeFloat, fail, lines, map, pure, sum, unlines)
import qualified Data.Scientific as Sci
import Data.Void
appendFile :: Packaging.PrimitiveDefinition
appendFile =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.appendFile"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Append bytes to the end of a file."),
Packaging.entityMetadataComments = [
"appendFile(path, contents) describes an effectful computation which attempts to append the raw bytes contents to the end of the file at path, creating the file if it does not exist. Unlike writeFile, existing contents are preserved. File I/O is byte-oriented; to append text, encode it to bytes first (e.g. via hydra.core.lib.text.encodeUtf8). A recoverable file-system failure is returned as left(error); success is returned as right(unit)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.appendFile.preservesExistingContentsAndAppends"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "appendFile adds the given bytes to the end of a file's existing contents, preserving what was already there, rather than replacing it as writeFile does."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path of the file to append to"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "contents"),
Typing.parameterDescription = (Just "the raw bytes to append"),
Typing.parameterType = (Model.TypeLiteral Model.LiteralTypeBinary),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = Model.TypeUnit})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
copy :: Packaging.PrimitiveDefinition
copy =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.copy"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Copy a file, or a directory tree, to a destination path."),
Packaging.entityMetadataComments = [
"copy(recursive, source, destination) describes an effectful computation which attempts to copy source to destination. When recursive is false, source must be a single file. When recursive is true, source may be a directory, whose entire tree is copied. Copying is performed by the host operating system rather than by reading and rewriting contents, preserving binary data and avoiding a round trip through the language runtime. A recoverable file-system failure is returned as left(error); success is returned as right(unit).",
"Deprecated since 0.18. Use: copyFile."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = Nothing,
Packaging.lifecycleInfoDeprecatedSince = (Just (Packaging.Version "0.18"))})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.copy.copiesSingleFile"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "copy with recursive=false duplicates a single file's contents at the destination path."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.copy.copiesDirectoryTreeWhenRecursive"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "copy with recursive=true duplicates an entire directory tree, including nested files, at the destination path, succeeding even when the destination directory already exists."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.copy.errorsOnNonRecursiveDirectory"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "copy with recursive=false on a directory source yields an error, rather than silently copying only the directory entry or a subset of its contents."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "recursive"),
Typing.parameterDescription = (Just "whether to copy a directory tree rather than a single file"),
Typing.parameterType = (Model.TypeLiteral Model.LiteralTypeBoolean),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "source"),
Typing.parameterDescription = (Just "the path to copy from"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "destination"),
Typing.parameterDescription = (Just "the path to copy to"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = Model.TypeUnit})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
createDirectory :: Packaging.PrimitiveDefinition
createDirectory =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.createDirectory"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Create a directory."),
Packaging.entityMetadataComments = [
"createDirectory(recursive, path) describes an effectful computation which attempts to create a directory at path. When recursive is false this corresponds to POSIX mkdir: it fails if path already exists or if a parent is missing. When recursive is true, any missing parent directories are created as well (as with mkdir -p) and an already-existing directory is not an error. A recoverable file-system failure is returned as left(error); success is returned as right(unit).",
"0.18 is planned to drop the leading recursive flag in favor of a flagless createDirectoryTree primitive, mirroring the copy/copyFile+copyTree split; not yet implemented."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.createDirectory.createsDirectoryThatThenExists"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "createDirectory creates a directory at the given path such that a subsequent exists check on that path reports true."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "recursive"),
Typing.parameterDescription = (Just "whether to create missing parent directories as well"),
Typing.parameterType = (Model.TypeLiteral Model.LiteralTypeBoolean),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path of the directory to create"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = Model.TypeUnit})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
createSymlink :: Packaging.PrimitiveDefinition
createSymlink =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.createSymlink"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Create a symbolic link."),
Packaging.entityMetadataComments = [
"createSymlink(target, link) describes an effectful computation which attempts to create a symbolic link at link, pointing to target (POSIX symlink). target is stored verbatim; it may be a relative path, and it need not exist. There is no force flag: if link already exists (including as a dangling symbolic link), the computation fails with left(alreadyExists); a caller that wants replace-if-exists semantics should compose status(false, link), removeFile, and createSymlink. A missing parent directory yields left(notFound); a host or file system which refuses to create the link (e.g. an unprivileged process on Windows, or an unsupported file system) yields left(permissionDenied) or left(other) as appropriate. A recoverable file-system failure is returned as left(error); success is returned as right(unit)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17.6")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.createSymlink.createsLinkObservableAsLinkType"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "createSymlink creates a symbolic link such that status(followLinks=false) on the link path reports fileType link; status(followLinks=true) on the link path reports the metadata of the link's target (not the link itself) when the target exists."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.createSymlink.allowsDanglingTargets"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "createSymlink succeeds even when the target does not exist, creating a dangling link; the dangling link is itself reported as present by exists (observed via status, not treated as absent), and still reports fileType link under status(followLinks=false), but is reported as notFound when followed via status(followLinks=true)."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.createSymlink.preservesTargetVerbatim"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "createSymlink stores the target path exactly as given, including a relative path, with no resolution or canonicalization; readSymlink returns that exact stored target."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.createSymlink.errorsOnExistingLinkPath"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "createSymlink fails (there is no force/replace flag) when the link path already exists, whether that existing entry is a regular file or another symbolic link (including a dangling one)."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "target"),
Typing.parameterDescription = (Just "the path that the new symbolic link will point to"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "link"),
Typing.parameterDescription = (Just "the path of the symbolic link to create"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = Model.TypeUnit})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
exists :: Packaging.PrimitiveDefinition
exists =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.exists"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Test whether a path exists."),
Packaging.entityMetadataComments = [
"exists(path) describes an effectful computation which reports whether anything exists at path, whether a file, directory, or other type of file. It does not error when the path is absent; a missing path is reported as right(false). Use status to obtain the type of an existing path. A recoverable file-system failure is returned as left(error)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.exists.falseForMissingPath"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "exists returns right(false) for a missing path, without erroring on absence."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.exists.trueAfterCreation"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "exists returns right(true) for a path immediately after a file or directory has been created there."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path to test for existence"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = (Model.TypeLiteral Model.LiteralTypeBoolean)})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
listDirectory :: Packaging.PrimitiveDefinition
listDirectory =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.listDirectory"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "List the immediate entries of a directory."),
Packaging.entityMetadataComments = [
"listDirectory(path) describes an effectful computation which returns the immediate entries of the directory at path, excluding the special entries \".\" and \"..\". The result is one level deep and is not ordered; to traverse a tree recursively, recurse using status. A recoverable file-system failure is returned as left(error)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.listDirectory.listsImmediateEntries"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "listDirectory returns exactly the immediate entries of the directory, one entry per file actually present, excluding the special \".\" and \"..\" entries."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path of the directory to list"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = (Model.TypeList (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")))})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
readFile :: Packaging.PrimitiveDefinition
readFile =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.readFile"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Read the complete contents of a file as raw bytes."),
Packaging.entityMetadataComments = [
"readFile(path) describes an effectful computation which attempts to read the entire contents of the file at path as raw bytes, with no character decoding or newline translation. To interpret the result as text, decode it (e.g. via hydra.core.lib.text.decodeUtf8). A recoverable file-system failure is returned as left(error); success is returned as right(contents)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.readFile.roundTripsWithWriteFile"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "readFile returns exactly the bytes most recently written to a file via writeFile (and any subsequent appendFile calls), byte-exactly, with no character decoding or translation."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path of the file to read"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = (Model.TypeLiteral Model.LiteralTypeBinary)})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
readSymlink :: Packaging.PrimitiveDefinition
readSymlink =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.readSymlink"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Read the target of a symbolic link."),
Packaging.entityMetadataComments = [
"readSymlink(path) describes an effectful computation which attempts to read the target of the symbolic link at path (POSIX readlink). This is a single-hop, unresolved read: the target is returned exactly as stored, with no chain resolution or canonicalization; a relative target is returned relative, and a dangling target (one that does not exist) is returned as-is. To resolve a chain of links to a canonical path, compose repeated calls to readSymlink and status. A missing path yields left(notFound); a path which exists but is not a symbolic link yields left(invalidPath). A recoverable file-system failure is returned as left(error); success is returned as right(target)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17.6")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.readSymlink.returnsStoredTargetVerbatim"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "readSymlink returns the target exactly as stored by createSymlink, with no chain resolution or canonicalization, including a relative target returned relative."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.readSymlink.errorsOnNonLinkOrMissingPath"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "readSymlink yields left(invalidPath) when the path exists but is not a symbolic link, and left(notFound) when the path does not exist at all -- two distinct error conditions, neither of which is confused with a successful read."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path of the symbolic link to read"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath"))})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
removeDirectory :: Packaging.PrimitiveDefinition
removeDirectory =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.removeDirectory"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Remove a directory."),
Packaging.entityMetadataComments = [
"removeDirectory(recursive, path) describes an effectful computation which attempts to remove the directory at path. When recursive is false this corresponds to POSIX rmdir: it fails unless the directory is empty. When recursive is true, the directory and its entire contents are removed (as with rm -r). Removal is performed by the host operating system rather than by walking and deleting entries individually. A recoverable file-system failure is returned as left(error); success is returned as right(unit).",
"0.18 is planned to drop the leading recursive flag in favor of a flagless removeDirectoryTree primitive, mirroring the copy/copyFile+copyTree split; not yet implemented."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.removeDirectory.removesEmptyDirectoryWhenNonRecursive"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "removeDirectory with recursive=false removes an empty directory, so that it no longer exists."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.removeDirectory.errorsOnNonEmptyDirectoryWhenNonRecursive"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "removeDirectory with recursive=false on a non-empty directory yields an error, rather than silently removing it or its contents."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.removeDirectory.removesPopulatedDirectoryWhenRecursive"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "removeDirectory with recursive=true removes a directory and its entire contents, so that the directory no longer exists."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "recursive"),
Typing.parameterDescription = (Just "whether to remove the directory's contents as well"),
Typing.parameterType = (Model.TypeLiteral Model.LiteralTypeBoolean),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path of the directory to remove"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = Model.TypeUnit})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
removeFile :: Packaging.PrimitiveDefinition
removeFile =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.removeFile"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Remove a file."),
Packaging.entityMetadataComments = [
"removeFile(path) describes an effectful computation which attempts to remove the file at path (POSIX unlink). A recoverable file-system failure is returned as left(error); success is returned as right(unit)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.removeFile.deletesFileSoItNoLongerExists"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "removeFile deletes the file at the given path, so that a subsequent exists check reports false."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path of the file to remove"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = Model.TypeUnit})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
rename :: Packaging.PrimitiveDefinition
rename =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.rename"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Rename or move a file or directory."),
Packaging.entityMetadataComments = [
"rename(source, destination) describes an effectful computation which attempts to rename the file or directory at source to destination. When source and destination are on the same file system this is atomic (POSIX rename) and cannot be reproduced by a copy followed by a delete. A recoverable file-system failure is returned as left(error); success is returned as right(unit)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.rename.movesToNewPathPreservingContents"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "rename moves a file (or directory) from source to destination, such that the original contents are readable at the destination path afterward."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "source"),
Typing.parameterDescription = (Just "the path to rename from"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "destination"),
Typing.parameterDescription = (Just "the path to rename to"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = Model.TypeUnit})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
status :: Packaging.PrimitiveDefinition
status =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.status"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Retrieve metadata about a file or directory."),
Packaging.entityMetadataComments = [
"status(followLinks, path) describes an effectful computation which retrieves metadata about the file system entry at path, including its type, size, and modification time. When followLinks is true, this corresponds to POSIX stat: if path is a symbolic link, the metadata describes the link's target, and a dangling link (whose target does not exist) yields left(notFound). When followLinks is false, this corresponds to POSIX lstat: the metadata describes the link itself, with fileType link, a size equal to the length of the stored target path, and the link's own timestamps; a dangling link is not an error in this mode. status(false, path) is the only way to observe fileType link; status(true, path) never produces it, since a followed link's metadata is always that of its (non-link) target. For paths that are not symbolic links, both modes report identical metadata. A path which does not exist yields left(notFound); other recoverable file-system failures are also returned as left(error). Use exists for a boolean presence check that does not error on absence."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.status.reportsCorrectTypeAndSizeForRegularFileAndDirectory"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "status reports the correct fileType and size for a regular file (size equal to its byte count) and reports directory as the fileType for a directory."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.status.followLinksControlsLinkResolution"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "status(followLinks=false) reports the metadata of a symbolic link itself (fileType link), while status(followLinks=true) on the same path reports the metadata of the link's target (its true fileType, not link) when the target exists -- the only way to observe fileType link is followLinks=false."},
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.status.notFoundOnMissingOrDanglingTarget"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "status yields left(notFound) for a path that does not exist, and also for a dangling symbolic link when followed via followLinks=true (even though the dangling link itself is not an error under followLinks=false)."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "followLinks"),
Typing.parameterDescription = (Just "whether to resolve symbolic links (true reproduces the previous, follow, behavior; false inspects the entry itself)"),
Typing.parameterType = (Model.TypeLiteral Model.LiteralTypeBoolean),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path to retrieve metadata for"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = (Model.TypeVariable (Model.Name "hydra.core.file.FileStatus"))})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}
writeFile :: Packaging.PrimitiveDefinition
writeFile =
Packaging.PrimitiveDefinition {
Packaging.primitiveDefinitionName = (Model.Name "hydra.core.lib.files.writeFile"),
Packaging.primitiveDefinitionMetadata = (Just (Packaging.EntityMetadata {
Packaging.entityMetadataDescription = (Just "Write raw bytes as the complete contents of a file."),
Packaging.entityMetadataComments = [
"writeFile(path, contents) describes an effectful computation which attempts to replace the file at path with the raw bytes contents, with no character encoding or newline translation. To write text, encode it to bytes first (e.g. via hydra.core.lib.text.encodeUtf8). A recoverable file-system failure is returned as left(error); success is returned as right(unit)."],
Packaging.entityMetadataSeeAlso = [],
Packaging.entityMetadataLifecycle = (Just (Packaging.LifecycleInfo {
Packaging.lifecycleInfoAvailableSince = (Just (Packaging.Version "0.17")),
Packaging.lifecycleInfoDeprecatedSince = Nothing})),
Packaging.entityMetadataProvisions = [
Packaging.Provision {
Packaging.provisionName = (Model.Name "hydra.core.lib.files.writeFile.replacesCompleteFileContents"),
Packaging.provisionKind = Packaging.ProvisionKindRequirement,
Packaging.provisionStatement = "writeFile replaces the complete contents of the file at the given path with the given bytes, creating the file if it does not already exist."}]})),
Packaging.primitiveDefinitionSignature = Typing.TermSignature {
Typing.termSignatureTypeParameters = [],
Typing.termSignatureParameters = [
Typing.Parameter {
Typing.parameterName = (Model.Name "path"),
Typing.parameterDescription = (Just "the path of the file to write"),
Typing.parameterType = (Model.TypeVariable (Model.Name "hydra.core.file.FilePath")),
Typing.parameterIsLazy = False},
Typing.Parameter {
Typing.parameterName = (Model.Name "contents"),
Typing.parameterDescription = (Just "the raw bytes to write as the file's contents"),
Typing.parameterType = (Model.TypeLiteral Model.LiteralTypeBinary),
Typing.parameterIsLazy = False}],
Typing.termSignatureResult = Typing.Result {
Typing.resultDescription = Nothing,
Typing.resultType = (Model.TypeEffect (Model.TypeEither (Model.EitherType {
Model.eitherTypeLeft = (Model.TypeVariable (Model.Name "hydra.core.error.file.FileError")),
Model.eitherTypeRight = Model.TypeUnit})))}},
Packaging.primitiveDefinitionIsPure = False,
Packaging.primitiveDefinitionIsTotal = True,
Packaging.primitiveDefinitionDefaultImplementation = Nothing}