Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Build.Task.Opaque
Description
Opaque monadic tasks, whose inputs and outputs can be dynamic.
Synopsis
- type Variable = String
- data Key a where
- type Get k f = forall a. k a -> f a
- type Put k f = forall a. k a -> a -> f ()
- type Task k a = forall f. Monad f => Get k f -> Put k f -> f a
- type TaskName = String
- data NamedTask k = NamedTask {}
- type Tasks k = [NamedTask k]
- type BlackBox = Task Key ()
- type BlackBoxes = Tasks Key
- tasks :: BlackBoxes
- build :: BlackBox
- release :: BlackBox
- compile :: FilePath -> FilePath -> BlackBox
- link :: FilePath -> FilePath -> BlackBox
- data LogEntry k where
- type Log k = [LogEntry k]
- hasWrongGet :: Log Key -> Key a -> a -> Bool
- execute :: forall m k. Monad m => Get k m -> Put k m -> Task k () -> m (Log k)
- newtype Store = Store {}
- putValue :: Key a -> a -> Store -> Store
- exampleStore :: Store
- type Graph = TaskName -> Maybe (Log Key)
- blindBuild :: BlackBoxes -> Store -> Graph -> (Store, Graph)
- type ShowKey k = forall a. k a -> String
- showKey :: ShowKey Key
- showValue :: Key a -> a -> String
- getIO :: Get Key IO
- putIO :: Put Key IO
Documentation
A collection of keys for accessing files, environment variables, and
contents of directories. Directories are somewhat magic, because their values
are derived from File
keys, i.e. creating a new file in a directory
requires updating the the corresponding Dir
key.
type Put k f = forall a. k a -> a -> f () Source #
Write a key's value in a computation context f
. Note: the type can be
changed to forall a. k a -> f a -> f a
to allow for static analysis of
applicative and selective build tasks, since we cannot have a
in a static
context f
, e.g. in Const
. See more details in Section 5.3 of this paper:
https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf.
type Task k a = forall f. Monad f => Get k f -> Put k f -> f a Source #
A build task is a stateful computation in a monadic context f
that is
given two callbacks: for reading and writing values to a key/value store.
type TaskName = String Source #
A unique task identifier, e.g. the path to the corresponding build script.
A task along with its unique identifier.
type Tasks k = [NamedTask k] Source #
A collection of build tasks using the same read and write interface.
type BlackBox = Task Key () Source #
An example type of "black box" build tasks: we can only find out what they read and write by executing them in a monadic context.
type BlackBoxes = Tasks Key Source #
Multiple black boxes, e.g. a collection of build scripts lying around.
tasks :: BlackBoxes Source #
An example collection of black boxes.
A typical build script that compiles a couple of C files, possibly depending on some header files, and then links the resulting objects into an executable.
A script for packaging the contents of the directory out
in an archive.
Note that if called prematurely, it will miss some of the release files and
will succeed, yielding an incomplete archive. The task will therefore need
to be rerun whenever the key Dir "out"
is updated.
compile :: FilePath -> FilePath -> BlackBox Source #
Compile a C source file, possibly including the lib.h
header.
link :: FilePath -> FilePath -> BlackBox Source #
Link object files in a given directory, producing an executable. Note that
this task can fail if run prematurely i.e. when some object files have not
yet been placed in the obj
directory, since some symbols will be undefined.
data LogEntry k where Source #
A task execution log entry, recording either a read from a key and the obtained value, or a write to a key, along with the written value.
An association of keys to values.
exampleStore :: Store Source #
blindBuild :: BlackBoxes -> Store -> Graph -> (Store, Graph) Source #
A build system that builds a collection of black box tasks by executing them blindly, and recording the resulting dependencies.