Module Digital_components.Step_monad

type ('a, 'i, 'o) t = ('a, 'i, 'o) Step_core.Computation.Monadic.t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> ('i -> Sexplib0.Sexp.t) -> ('o -> Sexplib0.Sexp.t) -> ('a, 'i, 'o) t -> Sexplib0.Sexp.t
include Base.Monad.S3 with type ('a, 'b, 'c) t := ('a, 'b, 'c) t
val return : 'a 'i 'p 'q. 'a -> ('a, 'p, 'q) t

Convert a value to a t.

val map : 'a 'b 'i 'j 'p 'q. ('a, 'p, 'q) t -> f:('a -> 'b) -> ('b, 'p, 'q) t

Transforms the contents of a t.

val bind : 'a 'b 'i 'j 'k 'p 'q. ('a, 'p, 'q) t -> f:('a -> ('b, 'p, 'q) t) -> ('b, 'p, 'q) t

Sequences computations. bind t ~f computes f v for value(s) v in t. Well-behaved monads satisfy these "laws" (where ( >>= ) is the infix bind operator):

  • map t ~f is equivalent to bind t ~f:(fun x -> return (f x))
  • return x >>= f is equivalent to f x
  • t >>= return is equivalent to t
  • (t >>= f) >>= g is equivalent to t >>= fun x -> f x >>= g
val join : 'a 'i 'j 'k 'p 'q. (('a, 'p, 'q) t, 'p, 'q) t -> ('a, 'p, 'q) t

Combines nested t into just one layer. Equivalent to bind t ~f:Fn.id.

val ignore_m : 'a 'i 'j 'p 'q. ('a, 'p, 'q) t -> (unit, 'p, 'q) t

Ignores contained values of t. Equivalent to map t ~f:ignore.

val all : 'a 'i 'p 'q. ('a, 'p, 'q) t list -> ('a list, 'p, 'q) t

Combines a list of t.

val all_unit : 'i 'p 'q. (unit, 'p, 'q) t list -> (unit, 'p, 'q) t

Combines a list of t whose contents are unimportant.

val (>>=) : 'a 'b 'i 'j 'k 'p 'q. ('a, 'p, 'q) t -> ('a -> ('b, 'p, 'q) t) -> ('b, 'p, 'q) t

Infix bind.

val (>>|) : 'a 'b 'i 'j 'p 'q. ('a, 'p, 'q) t -> ('a -> 'b) -> ('b, 'p, 'q) t

Infix map.

module Monad_infix : sig ... end
module Let_syntax : sig ... end
val next_step : Base.Source_code_position.t -> 'o -> ('i, 'i, 'o) t
val thunk : (Base.unit -> ('a, 'i, 'o) t) -> ('a, 'i, 'o) t
val output_forever : 'o -> (_, _, 'o) t
val for_ : Base.int -> Base.int -> (Base.int -> (Base.unit, 'i, 'o) t) -> (Base.unit, 'i, 'o) t

for_ i j f does f i, f (i+1), ... f j in sequence. If j < i, then for_ i j immediately returns unit.

val delay : 'o -> num_steps:Base.int -> (Base.unit, _, 'o) t

delay o ~num_steps outputs o for num_steps and then returns unit. delay raises if num_steps < 0.

val repeat : count:Base.int -> (Base.unit -> (Base.unit, 'i, 'o) t) -> (Base.unit, 'i, 'o) t

repeat ~count f does f () count times. repeat raises if count < 0.

val wait : output:'o -> until:('i -> Base.bool) -> (Base.unit, 'i, 'o) t
module Event : sig ... end

An event is a value that will at some point in time (possibly the past, possibly the future) transition from "undetermined" to "determined", with some value. One can wait_for an event in a computation.

val wait_for : 'a Event.t -> output:'o -> ('a, _, 'o) t

wait_for event ~output outputs output until the step at which event becomes determined, at which point the wait_for proceeds.

module Component_finished : sig ... end
val spawn : ?update_children_after_finish:Base.bool -> ?period:Base.int -> Base.Source_code_position.t -> start:('i_c -> (('a, 'o_c) Component_finished.t, 'i_c, 'o_c) t) -> input:'i_c Data.t -> output:'o_c Data.t -> child_input:(parent:'i -> 'i_c) -> include_child_output:(parent:'o -> child:'o_c -> 'o) -> (('a, 'o_c) Component_finished.t Event.t, 'i, 'o) t

spawn creates a child computation that runs start. spawn returns on the current step, and the child starts on the next step. The parent computation uses child_input to adjust its input into the form that the child computation sees, and include_child_output to incorporate the child's output into its output.

When update_children_after_finish, unfinished tasks spawned from within start will be executed even after start completes.

val create_component : ?period:Base.int -> created_at:Base.Source_code_position.t -> update_children_after_finish:Base.bool -> start:('i -> (('a, 'o) Component_finished.t, 'i, 'o) t) -> input:'i Data.t -> output:'o Data.t -> Base.unit -> ('i, 'o) Component.t * ('a, 'o) Component_finished.t Event.t

create_component creates a Component.t that runs the computation described by start. When update_children_after_finish is set to true, all component's children will be updated even after the child terminates. This will result in tasks spawned from within the child task to execute even after the child terminates.

val run_effectful_computation : (('i, 'o) Step_core.Computation.Eff.Handler.t @ local -> 'a) -> ('a, 'i, 'o) t