| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ivory.Artifact
- data Artifact
- artifactFileName :: Artifact -> FilePath
- artifactFile :: FilePath -> IO FilePath -> Artifact
- artifactCabalFile :: IO FilePath -> FilePath -> Artifact
- artifactText :: FilePath -> Text -> Artifact
- artifactString :: FilePath -> String -> Artifact
- artifactTransform :: (Text -> Text) -> Artifact -> Artifact
- artifactTransformString :: (String -> String) -> Artifact -> Artifact
- artifactTransformErr :: (Text -> Either String Text) -> Artifact -> Artifact
- artifactTransformErrString :: (String -> Either String String) -> Artifact -> Artifact
- artifactPath :: FilePath -> Artifact -> Artifact
- putArtifact :: FilePath -> Artifact -> IO (Maybe String)
- putArtifact_ :: FilePath -> Artifact -> IO ()
- printArtifact :: Artifact -> IO ()
- mightBeEqArtifact :: Artifact -> Artifact -> Bool
- data Located a
- mightBeEqLocatedArtifact :: Located Artifact -> Located Artifact -> Bool
Ivory Artifacts
Artifacts permit the user to generate non-Ivory language files
as part of an Ivory program's build process. Artifacts are typically
used to encapsulate helper code (such as Ivory.Stdlib's string functions
helper .c and .h files) or to generate debug or metadata output. The
contents of an Artifact are given by some external file, or as a string.
Artifacts are exposed as an abstract type Artifact with a set of
constructors, an accessor artifactFileName, and two functions,
putArtifact and printArtifact, which are used to write an
Artifacts to a file or print it to stdout, respectively.
Users may specify transformations on the contents of an artifact. Optionally, these transformations can throw an error. This is useful when using artifact files as templates.
Gives the file name that will be used when writing the Artifact to the
filesystem.
artifactFileName :: Artifact -> FilePath Source #
Artifact constructors
artifactFile creates an Artifact from an output filename of type
FilePath and an input filepath of type `IO FilePath`. The output filename
should be a simple filename, any directory information will be dropped. The
input filepath should be an absolute path. The input filepath is in the IO
monad for compatiblility with Cabal's getDataDir data files functionality.
artifactCabalFile creates an Artifact given an input directory of
type `IO FilePath` and an input filepath, relative to the input directory
in the preceeding argument, of type FilePath.
This function is designed to be used with a Cabal Paths_(packagename)
getDataDir, which has type `IO FilePath`, and a path to a file inside the
data directory. It is implemented in terms of artifactFileName. The
output filename is given by dropping directory information from the input
filepath.
artifactText creates an Artifact from an output filename of type
FilePath and with contents of type Text.
artifactString creates an Artifact from an output filename of type
FilePath with contents of type String. Implemented in terms of
artifactText.
artifactTransform and artifactTransformString specify a
transformation on the contents of an Artifact.
artifactTransformErr and artifactTransformErrString specify a
transformation on the contents of an Artifact which may give an error.
artifactPath prepends a FilePath to the output file path.
Artifact actions
Takes a directory of type FilePath and an Artifact
writes each Artifact to the file system or gives an error explaining why
not. `Maybe String` containins errors encountered when an Artifact is
transformed, or specified by an input filename which does not exist.
like putArtifact but ignores any errors.
Takes an Artifact and prints it, or an appropriate error message, to
stdout.
printArtifact :: Artifact -> IO () Source #
Takes a guess at whether two artifacts might be equal.
In the build, we generally want to put artifacts in one of three locations: somewhere relative to the root directory of the build output, somewhere relative to the sources, or somewhere relative to the includes (headers).