Module Env.Over

Parameters

Signature

type env = Env.t

The encapsulated environment.

type 'a comonad

The inner comonad.

type 'a t = env * 'a comonad

The type held by the env comonad.

val lower : 'a t -> 'a comonad

get the underlying comonad.

val run : 'a t -> env * 'a comonad

Unwrap the env computation.

val ask : 'a t -> env

Retrieves the environment.

val asks : (env -> 'b) -> 'a t -> 'b

Retrieves the environment and apply a function.

val local : (env -> env) -> 'a t -> 'a t

Modifies the environment using the specified function.

module Local (Env : Preface_specs.Types.T0) : sig ... end

Perform local with an other environment.

Comonad

Type
Type
Functions
val duplicate : 'a t -> 'a t t

Dual of join.

val map : ('a -> 'b) -> 'a t -> 'b t

Mapping over t from 'a to 'b.

val extend : ('a t -> 'b) -> 'a t -> 'b t

Dual of bind.

val extract : 'a t -> 'a

Extract a 'a from t. Dual of return.

val compose_left_to_right : ('a t -> 'b) -> ('b t -> 'c) -> 'a t -> 'c

Composing monadic functions using Co-Kleisli Arrow (from left to right).

val lift : ('a -> 'b) -> 'a t -> 'b t

Mapping over t from 'a to 'b.

val lift2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

Lift a binary function that acts on arbitrary values into a function that acts t values.

val lift3 : ('a -> 'b -> 'c -> 'd) -> 'a t -> 'b t -> 'c t -> 'd t

Lift a ternary function that acts on arbitrary values into a function that acts t values.

val compose_right_to_left : ('b t -> 'c) -> ('a t -> 'b) -> 'a t -> 'c

Composing co-monadic functions using Co-Kleisli Arrow (from right to left).

val replace : 'a -> 'b t -> 'a t

Create a new t, replacing all values of the given functor by given a value of 'a.

val void : 'a t -> unit t

Create a new t, replacing all values in the given functor by unit.

Infix operators
module Infix : Preface_specs.Indexed_comonad.INFIX with type ('a, 'index) t := 'a t
val (=>>) : 'a t -> ('a t -> 'b) -> 'b t

Infix flipped version of CORE.extend.

val (<<=) : ('a t -> 'b) -> 'a t -> 'b t

Infix version of CORE.extend.

val (=>=) : ('a t -> 'b) -> ('b t -> 'c) -> 'a t -> 'c

Infix version of CORE.compose_left_to_right.

val (=<=) : ('b t -> 'c) -> ('a t -> 'b) -> 'a t -> 'c

Infix version of OPERATION.compose_right_to_left.

val (<@@>) : 'a t -> ('a -> 'b) t -> 'b t

Applicative functor of ('a -> 'b) t over ('a, 'index) t to ('b, 'index) t.

val (<@>) : ('a -> 'b) t -> 'a t -> 'b t

Applicative functor of ('a -> 'b) t over ('a, 'index) t to ('b, 'index) t.

val (@>) : unit t -> 'b t -> 'b t

Discard the value of the first argument.

val (<@) : 'a t -> unit t -> 'a t

Discard the value of the second argument.

val (<$>) : ('a -> 'b) -> 'a t -> 'b t

Infix version of CORE.map.

val (<&>) : 'a t -> ('a -> 'b) -> 'b t

Flipped and infix version of CORE.map.

val (<$) : 'a -> 'b t -> 'a t

Infix version of OPERATION.replace.

val ($>) : 'a t -> 'b -> 'b t

Flipped and infix version of OPERATION.replace.

Syntax
module Syntax : Preface_specs.Indexed_comonad.SYNTAX with type ('a, 'index) t := 'a t
val let@ : 'a t -> ('a t -> 'b) -> 'b t

Syntactic shortcuts for version of CORE.extend:

let@ x = e in f is equals to extend f e.

include Preface_specs.Indexed_functor.SYNTAX with type ('a, 'index) t := 'a t
val let+ : 'a t -> ('a -> 'b) -> 'b t

let operator for mapping.

val env : env -> 'a -> 'a t

Create Env using an environment and a value.

val run_identity : 'a t -> env * 'a

Run the env through the identity.

Functor

module Functor : Preface_specs.FUNCTOR with type 'a t = 'a t

Invariant Functor

module Invariant : Preface_specs.INVARIANT with type 'a t = 'a t