package dolmen_loop

  1. Overview
  2. Docs

Module Pipeline.MakeSource

Concrete pipelines.

Parameters

Signature

Type definitions

Sourcetype ('st, 'a, 'b) op

An operator from values of type 'a to value sof type 'b, and where a state value of type 'st is carried throughout.

Sourcetype ('st, 'a, 'b) t

The type of pipelines from values of type 'a to values of type 'b, with state values of type 'st.

Sourcetype 'st merge = 'st -> 'st -> 'st

Merge function used at the end of a fixpoint to get the resulting state.

Sourcetype ('st, 'a) fix = [
  1. | `Ok
  2. | `Gen of 'st merge * ('st -> 'st * 'a option)
]

Type used to fixpoint expanding statements such as includes.

Sourcetype ('a, 'b) cont = [
  1. | `Done of 'a
  2. | `Continue of 'b
]

Type used for continuation operators, allowing to leave the pipeline early.

Sourcetype 'st k_exn = {
  1. k : 'a. 'st -> Printexc.raw_backtrace -> exn -> 'a;
}

Exception continuation to provide when evaluating a pipeline manually, in order to evaluate an exception handler with the most up-to-date state.

Creating operators

Sourceval op : ?name:string -> ('st -> 'a -> 'st * 'b) -> ('st, 'a, 'b) op

Base constructor function for operators.

Sourceval apply : ?name:string -> ('a -> 'b) -> (_, 'a, 'b) op

Create an operator from a function

Sourceval iter_ : ?name:string -> ('a -> unit) -> (_, 'a, 'a) op

Perform the function's side-effect and return the same input.

Sourceval f_map : ?name:string -> ?test:('st -> 'a -> bool) -> ('st -> 'a -> 'st * 'b) -> ('st, 'a, ('a, 'b) cont) op

TODO: doc

Creating pipelines

Sourceval _end : (_, 'a, 'a) t
Sourceval (@>>>) : ('st, 'a, 'b) op -> ('st, 'b, 'c) t -> ('st, 'a, 'c) t

Add an operator at the beginning of a pipeline.

Sourceval (@>|>) : ('st, 'a, ('b, 'c) cont) op -> ('st, 'c, 'b) t -> ('st, 'a, 'b) t

Add a continuation operator, allowing to stop evaluation of the pipeline early.

Sourceval (@|||) : ('st, 'a, 'b) t -> ('st, 'b, 'c) t -> ('st, 'a, 'c) t

Concatenate two pipeline. Whenever possible it is best to use (@>>>), which creates tail-rec pipelines.

Sourceval fix : ('st, 'a, ('st, 'a) fix) op -> ('st, 'a, unit) t -> ('st, 'a, unit) t

Perform a fixpoint expansion

Evaluating pipelines

Sourceval eval : exn:'st k_exn -> ('st, 'a, 'b) t -> 'st -> 'a -> 'st * 'b

Evaluate a pipeline to a function.

Sourceval run : finally:(State.t -> (Printexc.raw_backtrace * exn) option -> State.t) -> (State.t -> State.t * 'a option) -> State.t -> (State.t, 'a, unit) t -> State.t

Loop the evaluation of a pipeline over a generator, and starting options.

  • parameter finally

    a function called at the end of every iteration (even if an exception has been raised)