package current
Install
Dune Dependency
Authors
-
TThomas Leonard <talex5@gmail.com>
-
AAntonin Décimo <antonin@tarides.com>
-
TTim McGilchrist <timmcgil@gmail.com>
-
CCraig Ferguson <me@craigfe.io>
-
EEtienne MARAIS <etienne@maiste.fr>
-
AAnil Madhavapeddy <anil@recoil.org>
-
David Allsopp
-
EEwan Mellor <ewan@tarides.com>
-
KKate <kit.ty.kate@disroot.org>
-
MMark Elvers <mark.elvers@tunbury.org>
-
PPuneeth Chaganti <punchagan@muse-amuse.in>
-
LLucas Pluvinage <lucas@tarides.com>
-
NNavin Keswani <navin@novemberkilo.com>
-
TThomas Gazagnaire <thomas@gazagnaire.org>
-
Patrick Ferris
-
AArthur Wendling <art.wendling@gmail.com>
-
AAnurag Soni <anurag@sonianurag.com>
-
AAmbre Austen Suhamy <ambre@tarides.com>
-
BBen Andrew <benmandrew@gmail.com>
-
GGargi Sharma <gs051095@gmail.com>
-
JJonathan Coates <git@squiddev.cc>
-
JJules Aguillon <juloo.dsi@gmail.com>
-
MMagnus Skjegstad <magnus@skjegstad.com>
-
SShon Feder <shon.feder@gmail.com>
-
Ssmolck <46855713+smolck@users.noreply.github.com>
-
Ttatchi <corentin.leruth@gmail.com>
Maintainers
Sources
md5=8a60e0b0860f6353c0e001d8d74a88ca
sha512=fddde66e3390afa4d46e2d121f2b510358ef853b81b691dbf482b0cfc8f56b21f5a0c43618e1818e6378b8897eca5811af7a995b42e1cb955647727cad877e05
doc/current.term/Current_term/Make/index.html
Module Current_term.Make
Source
Parameters
module Metadata : sig ... end
Signature
include S.TERM
with type metadata := Metadata.t
and type 'a primitive = ('a Output.t * Metadata.t option) Current_incr.t
An 'a t
is a term that produces a value of type 'a
.
Information about operations hidden behind a bind.
active x
is a term indicating that the result is not determined yet.
val state :
?hidden:bool ->
'a t ->
('a, [ `Active of Output.active | `Msg of string ]) result t
state t
always immediately returns a successful result giving the current state of t
.
catch t
successfully returns Ok x
if t
evaluates successfully to x
, or successfully returns Error e
if t
fails with error e
. If t
is active then catch t
will be active too.
Sequencing terms
Applicative operations
map f x
is a term that runs x
and then transforms the result using f
.
The optional equality function ?eq
defaults to physical equality. When f
produces an updated result following a change in x
, the equality function will be called with the previous and the new value eq b_old b_new
: returning true
indicates that the change can be ignored and should not propagate further down the pipeline.
map_error f x
is a term that runs x
and then transforms the error string (if any) using f
.
pair a b
is the pair containing the results of evaluating a
and b
(in parallel).
val list_map :
(module S.ORDERED with type t = 'a) ->
?collapse_key:string ->
?label:string ->
('a t -> 'b t) ->
'a list t ->
'b list t
list_map (module T) f xs
adds f
to the end of each input term and collects all the results into a single list.
val list_iter :
(module S.ORDERED with type t = 'a) ->
?collapse_key:string ->
?label:string ->
('a t -> unit t) ->
'a list t ->
unit t
Like list_map
but for the simpler case when the result is unit.
list_seq x
evaluates to a list containing the results of evaluating each element in x
, once all elements of x
have successfully completed.
option_map f x
is a term that evaluates to Some (f y)
if x
evaluates to Some y
, or to None
otherwise.
Like option_map
but for the simpler case when the result is unit.
option_seq None
is Current.return None
and option_seq (Some x)
is Current.map some x
. This is useful for handling optional arguments that are currents.
all xs
is a term that succeeds if every term in xs
succeeds. The labels are used if some terms fail, to indicate which ones are failing.
gate ~on:ctrl x
is the same as x
, once ctrl
succeeds.
Note: gate
does not delay x
; it only delays whatever you put after the gate. e.g.
let binary = build src in
let tests_ok = test binary in
binary |> gate ~on:tests_ok |> deploy
cutoff ~eq x
is the same as x
, but changes to x
that are equal according to eq
do not propagate further down. It should be used when values of type 'a
have a precise definition of equality to avoid triggering redundant work.
Diagram control
collapse ~key ~value ~input t
is a term that behaves just like t
, but when shown in a diagram it can be expanded or collapsed. When collapsed, it is shown as "input -> +
" and the user can expand it to show t
instead. The idea is that input
is a dependency of t
and the "+" represents everything in t
after that. key
and value
are used as the parameters (e.g. in a URL) to control whether this is expanded or not. For example collapse ~key:"repo" ~value:"mirage/mirage-www" ~input:repo (process repo)
Note: list_map ~collapse_key
provides an easy way to use this.
val collapse_list :
key:string ->
value:string ->
input:_ t ->
'a t list ->
'a t list * unit t
collapse_list ~key ~value ~input t
is a term that behaves just like t
list, but when shown in a diagram it can be expanded or collapsed.
with_context ctx f
is the term f ()
, where f
is evaluated in context ctx
. This means that ctx
will be treated as an input to all terms created by f
in the diagrams.
Monadic operations
N.B. these operations create terms that cannot be statically analysed until after they are executed.
bind f x
is a term that first runs x
to get y
and then behaves as the term f y
. Static analysis cannot look inside the f
function until x
is ready, so using bind
makes static analysis less useful. You can use the info
argument to provide some information here.
Primitives
primitive ~info f x
is a term that evaluates f
on each new value of x
. This is used to provide the primitive operations, which can then be combined using the other combinators in this module. info
is used to label the operation in the diagram.
component name
is used to annotate binds, so that the system can show a name for the operations hidden inside the bind's function. name
is used as the label for the bind in the generated dot diagrams. For convenience, name
can also be a format string.
observe x
evaluates the current state of term x
. A `Blocked
value occurs when the term failed because an upstream dependency errored.