Module Applicative.Make2Source

Produces a monad with two type parameters.

Parameters

module X : sig ... end

Signature

include S2 with type ('a, 'p) t := ('a, 'p) X.t
val return : 'a 'p 'q. 'a -> ('a, 'p) X.t

Convert a value to a t.

val apply : 'a 'b 'p 'q. ('a -> 'b, 'p) X.t -> ('a, 'p) X.t -> ('b, 'p) X.t

Applies the functions in one t to the values in another. Well-behaved applicatives satisfy these "laws", using <*> as infix apply:

  • return Fn.id <*> t is equivalent to t
  • return Fn.compose <*> tf <*> tg <*> tx is equivalent to tf <*> (tg <*> tx)
  • return f <*> return x is equivalent to return (f x)
  • tf <*> return x is equivalent to return (fun f -> f x) <*> tf
Sourceval both : 'a 'b 'p 'q. ('a, 'p) X.t -> ('b, 'p) X.t -> ('a * 'b, 'p) X.t

Combines values in two ts as tuples. Using <*> as infix apply, equivalent to return (fun a b -> a, b) <*> ta <*> tb.

Sourceval map : 'a 'b 'p 'q. ('a, 'p) X.t -> f:('a -> 'b) -> ('b, 'p) X.t

Transforms the contents of a t. Using <*> as infix apply, equivalent to return f <*> t.

Sourceval map2 : 'a 'b 'c 'p 'q. ('a, 'p) X.t -> ('b, 'p) X.t -> f:('a -> 'b -> 'c) -> ('c, 'p) X.t

Combines the contents of two ts. Using <*> as infix apply, equivalent to return f <*> ta <*> tb.

Sourceval map3 : 'a 'b 'c 'd 'p 'q. ('a, 'p) X.t -> ('b, 'p) X.t -> ('c, 'p) X.t -> f:('a -> 'b -> 'c -> 'd) -> ('d, 'p) X.t

Combines the contents of three ts. Using <*> as infix apply, equivalent to return f <*> ta <*> tb <*> tc.

Sourceval all : 'a 'p 'q. ('a, 'p) X.t list -> ('a list, 'p) X.t

Combines a list of t.

Sourceval all_unit : 'p 'q. (unit, 'p) X.t list -> (unit, 'p) X.t

Combines a list of t whose contents are unimportant.

Sourceval (<*>) : 'a 'b 'p 'q. ('a -> 'b, 'p) X.t -> ('a, 'p) X.t -> ('b, 'p) X.t
Sourceval (<*) : 'a 'p 'q. ('a, 'p) X.t -> (unit, 'p) X.t -> ('a, 'p) X.t
Sourceval (*>) : 'a 'p 'q. (unit, 'p) X.t -> ('a, 'p) X.t -> ('a, 'p) X.t
Sourceval (>>|) : 'a 'b 'p 'q. ('a, 'p) X.t -> ('a -> 'b) -> ('b, 'p) X.t
Sourcemodule Applicative_infix : sig ... end