Yocaml.TaskSourceTask 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.
lift f lift the function f into a task with an empty set of dependencies. Useful for transforming regular functions into tasks.
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.
with_default f g performs g if f returns right.
when_ pred when_true when_false performs when_true is pred returns true, when_false otherwise.
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.
Regular apply on a task. Since t is also an Applicative.
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.
val map5 :
('a -> 'b -> 'c -> 'd -> 'e -> 'f) ->
'a ct ->
'b ct ->
'c ct ->
'd ct ->
'e ct ->
'f ctLift 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 ctLift 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 ctLift 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 ctLift a 8-ary function.
x ||> f is f x.
a <+< b compose b and a and concat dynamic dependencies set.
a >+> b compose a and b and concat dynamic dependencies set.
f *<< t1 is compose (make Deps.empty f) t1.
t1 <<* f is compose t1 (make Deps.empty f).
f *>> t1 is compose (make Deps.empty f) t1.
t1 >>* f is compose t1 (make Deps.empty f).
t1 +++ t2 is choose t1 t2.
f <?< g performs g if f returns right.
f >?> g performs f if g returns right.
let+ x = t1 and+ y = t2 in f x y is f <$> t1 <*> t2.
has_dynamic_dependencies t returns true if task has dynamic dependencies, false otherwise.
dependencies_of t returns the dependencies set of a task.
action_of t returns the effectful function of a task.
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).
drop_first t discards the first element returned by a task.
drop_second t discards the second element returned by a task.
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.