package primavera

  1. Overview
  2. Docs

doc/primavera/Primavera/Result/index.html

Module Primavera.ResultSource

Complete interface built on top of Req.S2.

Types

Sourcetype ('a, 'b) output = ('a, 'b) result

The type of expression that dependency injection must produce.

Sourcetype ('a, 'e, 'handler) t

The type that describes a calculation that uses dependency injection. 'a is the normal form of the programme and 'handler is the object that describes the set of dependencies.

Running and performing

Sourceval run : handler:'handler -> ('a -> ('b, 'e, 'handler) t) -> 'a -> ('b, 'e) output

Performs a function computation with a given handler.

Sourceval run_computation : handler:'handler -> ('a, 'e, 'handler) t -> ('a, 'e) output

Performs a computation with a given handler.

Sourceval perform : ('handler -> ('a, 'e) output) -> ('a, 'e, 'handler) t

Convert a regular function (which takes an handler) into an performable effect.

Sourceval perform_value : ('handler -> 'a) -> ('a, 'e, 'handler) t

Convert a regular value (which takes an handler) into an performable effect.

Sourceval local : ('new_handler -> 'handler) -> ('a, 'e, 'handler) t -> ('a, 'e, 'new_handler) t

local f comp is the contramap (on the environment). This allows it to be changed in a computation.

Sourceval handler : ('handler, 'e, 'handler) t

handler get the handler for the current computation.

Regular functions

Sourceval return : 'a -> ('a, 'e, 'f) t

return x lift x in the context of the type t.

Sourceval map : ('a -> 'b) -> ('a, 'e, 'f) t -> ('b, 'e, 'f) t

map f x mapping from f over x. Lift a function from 'a -> 'b to a function from 'a t -> 'b t.

Sourceval apply : ('a -> 'b, 'e, 'f) t -> ('a, 'e, 'f) t -> ('b, 'e, 'f) t

apply f x given f and x apply f on x.

Sourceval bind : ('a, 'e, 'f) t -> ('a -> ('b, 'e, 'f) t) -> ('b, 'e, 'f) t

bind x f sequentially apply f on x.

Sourceval replace : 'a -> ('b, 'e, 'handler) t -> ('a, 'e, 'handler) t

replace x comp discard the result of comp by x.

Sourceval ignore : ('a, 'e, 'handler) t -> (unit, 'e, 'handler) t

ignore comp same as regular ignore function but for effectful computation.

Sourceval zip : ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('a * 'b, 'e, 'handler) t

zip a b is the monoidal product between a and b.

Sourceval join : (('a, 'e, 'handler) t, 'e, 'handler) t -> ('a, 'e, 'handler) t

join comp flatten the result of comp.

Sourceval compose : ('a -> ('b, 'e, 'handler) t) -> ('c -> ('a, 'e, 'handler) t) -> 'c -> ('b, 'e, 'handler) t

compose f g x is the kleisli composition of f and g.

Sourceval map2 : ('a -> 'b -> 'c) -> ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('c, 'e, 'handler) t

map2 lift a function 2-arity function.

Sourceval map3 : ('a -> 'b -> 'c -> 'd) -> ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('c, 'e, 'handler) t -> ('d, 'e, 'handler) t

map3 lift a function 3-arity function.

Sourceval map4 : ('a -> 'b -> 'c -> 'd -> 'e) -> ('a, 'e1, 'handler) t -> ('b, 'e1, 'handler) t -> ('c, 'e1, 'handler) t -> ('d, 'e1, 'handler) t -> ('e, 'e1, 'handler) t

map4 lift a function 4-arity function.

Sourceval map5 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f) -> ('a, 'e1, 'handler) t -> ('b, 'e1, 'handler) t -> ('c, 'e1, 'handler) t -> ('d, 'e1, 'handler) t -> ('e, 'e1, 'handler) t -> ('f, 'e1, 'handler) t

map5 lift a function 5-arity function.

Infix Operators

Sourcemodule Infix : sig ... end

Infix operators.

Binding Operators

Sourcemodule Syntax : sig ... end

Bindings operators.

Included operators

Sourceval (<$>) : ('a -> 'b) -> ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t

f <$> x is map f x (infix version of map)

Sourceval (<$) : 'a -> ('b, 'e, 'handler) t -> ('a, 'e, 'handler) t

a <$ x is replace a x (infix version of replace)

Sourceval ($>) : ('a, 'e, 'handler) t -> 'b -> ('b, 'e, 'handler) t

x $> a is replace a x (infix (flipped) version of replace)

Sourceval (<*>) : ('a -> 'b, 'e, 'handler) t -> ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t

f <*> x is apply f x (infix version of apply)

Sourceval (<&>) : ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('a * 'b, 'e, 'handler) t

a <&> b is zip a b (infix version of zip)

Sourceval (<*) : ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('a, 'e, 'handler) t

a <* b Perform a and b but discard b.

Sourceval (*>) : ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('b, 'e, 'handler) t

a *> b Perform a and b but discard a.

Sourceval (<<) : ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('a, 'e, 'handler) t

a << b Sequentially perform a following by b but discard b.

Sourceval (>>) : ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('b, 'e, 'handler) t

a >> b Sequentially perform a following by b but discard a.

Sourceval (>>=) : ('a, 'e, 'handler) t -> ('a -> ('b, 'e, 'handler) t) -> ('b, 'e, 'handler) t

m >>= f is bind m f (infix version of bind)

Sourceval (=<<) : ('a -> ('b, 'e, 'handler) t) -> ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t

f =<< m is bind m f (infix (flipped) version of bind)

Sourceval (<=<) : ('a -> ('b, 'e, 'handler) t) -> ('c -> ('a, 'e, 'handler) t) -> 'c -> ('b, 'e, 'handler) t

f <=< g is compose f g (infix version of compose)

Sourceval (>=>) : ('a -> ('b, 'e, 'handler) t) -> ('b -> ('c, 'e, 'handler) t) -> 'a -> ('c, 'e, 'handler) t

f >=> g is compose g f (infix (flipped) version of compose)

Sourceval (let+) : ('a, 'e, 'handler) t -> ('a -> 'b) -> ('b, 'e, 'handler) t

let+ x = m in f x is map (fun x -> f x) m.

(binding version of map)

Sourceval (and+) : ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('a * 'b, 'e, 'handler) t

let+ x = m and+ y = n in f x y is map (fun (x, y) -> f x y) (zip m n).

(binding version of zip)

Sourceval (let*) : ('a, 'e, 'handler) t -> ('a -> ('b, 'e, 'handler) t) -> ('b, 'e, 'handler) t

let* x = m in f x is bind m (fun x -> f x).

(binding version of bind)

Sourceval (and*) : ('a, 'e, 'handler) t -> ('b, 'e, 'handler) t -> ('a * 'b, 'e, 'handler) t

let* x = m and* y = n in f x y is bind (zip m n) (fun (x, y) -> f x y).

(binding version of zip)

Traversable API

Sourcemodule Traversable (T : Sig.Req.T2 with type ('a, 'b) applicative = ('a, 'b) output) : Sig.T2 with type 'a foldable := 'a T.foldable and type ('a, 'e, 'handler) applicative := ('a, 'e, 'handler) t

Traversable interface on top of Req.S2 for S2

Prebuilt instances

Sourcemodule List : Sig.T2 with type 'a foldable := 'a list and type ('a, 'e, 'handler) applicative := ('a, 'e, 'handler) t

Traversable interface on top of Req.S2 for S2