Library
Module
Module type
Parameter
Class
Class type
Task is the main abstraction used to describe an action (a task that produces an effect) associated with dependencies and a DSL for composing tasks together.
A task is a particular type of function, which produces an effect, associated with a set of dependencies. That's why it's a type parameterised by an input and an output.
make deps eff
Builds a task with a fixed set of dependencies and an action.
from_effect
is make Deps.empty
.
val lift : ?has_dynamic_dependencies:bool -> ('a -> 'b) -> ('a, 'b) t
lift f
lift the function f
into a task with an empty set of dependencies. Useful for transforming regular functions into tasks.
val id : ('a, 'a) t
Task is in fact a Strong Profonctor, and therefore an Arrow, hence the presence of an identity morphism, associated with an empty dependency set.
Building a construction pipeline involves composing tasks and merging their set of dependencies.
compose t2 t1
merges dependencies from t1
and t2
and produce a new action that sequentially performs t1
following by t2
.
rcompose t1 t2
merges dependencies from t1
and t2
and produce a new action that sequentially performs t1
following by t2
.
pre_compose f t
is compose (lift f) t
. It allows to composition between Task and regular function.
post_compose t f
is compose t (lift f)
. It allows to composition between Task and regular function.
pre_recompose f t
is rcompose (lift f) t
It allows to composition between Task and regular function.
post_recompose t f
is rcompose t (lift f)
It allows to composition between Task and regular function.
Since in t
, 'a
is contravariant and 'b
is covariant, we can imagine its profunctorial nature.
dimap f g t
contramap f
on t
and map g
on t
.
Profunctors with choice, to act on sum-types (using Either
to describe generic sums).
left t
expand the arrow to act only on the Left
part of the sum.
right t
expand the arrow to act only on the Right
part of the sum.
Split the input between the two argument arrows, re-tagging and merging their outputs.
Split the input between the two argument arrows, merging their outputs.
Profunctors with strength, to act on product-types (using ('a * 'b)
to describe generic products).
first t
expand the arrow to act only on the first part of the product.
second t
expand the arrow to act only on the second part of the product.
Split the input between the two argument arrows and combine their output.
Send the input to both argument arrows and combine their output.
Implement function application capabilities using Arrow Apply.
Removing the contravariant component of the profunctor, we have a covariant component that can be treated as a regular Functor. This makes it possible to have linking operators and to make the API potentially less conflicting.
type 'a ct = (unit, 'a) t
Just a type alias for reducing signatures verbosity
val pure : 'a -> 'a ct
Lift a regular value into a task.
select e f
apply f
if e
is Left
. It allow to skip effect using Right
.
branch x f g
if x
is Left
, it performs f
, otherwise it performs g
.
Lift a 4-ary function.
Lift a 5-ary function.
val map6 :
('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) ->
'a ct ->
'b ct ->
'c ct ->
'd ct ->
'e ct ->
'f ct ->
'g ct
Lift a 6-ary function.
val map7 :
('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g -> 'h) ->
'a ct ->
'b ct ->
'c ct ->
'd ct ->
'e ct ->
'f ct ->
'g ct ->
'h ct
Lift a 7-ary function.
val map8 :
('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g -> 'h -> 'i) ->
'a ct ->
'b ct ->
'c ct ->
'd ct ->
'e ct ->
'f ct ->
'g ct ->
'h ct ->
'i ct
Lift a 8-ary function.
module Infix : sig ... end
a <+< b
compose b
and a
and concat dynamic dependencies set.
a >+> b
compose a
and b
and concat dynamic dependencies set.
t1 +++ t2
is choose t1 t2
.
module Syntax : sig ... end
val has_dynamic_dependencies : (_, _) t -> bool
has_dynamic_dependencies t
returns true
if task has dynamic dependencies, false
otherwise.
destruct t
returns the triple of a dependencies set and an effectful callback and if the task is associated to dynamic dependencies. destruct
is dependencies_of t, action_of t, has_dynamic_dependencies t
no_dynamic_deps
makes an arrow static (does not attach it to any dynamic dependency set).
val drop_first : unit -> ('a * 'b, 'b) t
drop_first t
discards the first element returned by a task.
val drop_second : unit -> ('a * 'b, 'a) t
drop_second t
discards the second element returned by a task.
val empty_body : unit -> ('a, 'a * string) t
An arrow that attach an empty body
val const : 'a -> ('b, 'a) t
const x
is an arrow that discard the previous output to replace-it by k
.
with_dynamic_dependencies dependenices_list
allows to add a set of dynamic dependencies to a task. Even the set of dependencies looks static, it is mostly used for attaching dependencies like folders.
The API can change considerably when processing tasks with or without dynamic dependencies, so we are exposing two modules to simplify this processing.
module Static : sig ... end
Utilities for dealing with tasks without dynamic dependencies.
module Dynamic : sig ... end
Utilities for dealing with tasks with dynamic dependencies.