ivory-artifact-0.1.0.5: Manage additional data files during Ivory compilation.

Safe HaskellNone
LanguageHaskell2010

Ivory.Artifact

Contents

Synopsis

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.

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.

Takes a guess at whether two artifacts might be equal.

data Located a Source #

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).

Constructors

Root a 
Src a 
Incl a 

Instances

Functor Located Source # 

Methods

fmap :: (a -> b) -> Located a -> Located b #

(<$) :: a -> Located b -> Located a #

Eq a => Eq (Located a) Source # 

Methods

(==) :: Located a -> Located a -> Bool #

(/=) :: Located a -> Located a -> Bool #

Show a => Show (Located a) Source # 

Methods

showsPrec :: Int -> Located a -> ShowS #

show :: Located a -> String #

showList :: [Located a] -> ShowS #