Module Applicative.List
List
defines applications that work across all possible combinations of the items in the respective lists. This is often used to model non-determinism.
E.g., to get all pairs that can be formed by selecting first and second elements from the respective lists:
# let x = List.NonDet.((fun x y -> (x, y)) <@> [1;2] <*> ['a';'b']);;
- : (int * char) list = [(1, 'a'); (1, 'b'); (2, 'a'); (2, 'b')]
include Seed
include Functor.S
include Functor.Seed
type 'a t
The principle type.
The type constructor
t
is the mapping of objects taking every type'a
to a type'a t
.
val map : f:('a -> 'b) -> 'a t -> 'b t
map ~f
maps the functionf : 'a -> 'b
to a function'f T : 'a T -> 'b T
.As an example, if
T (x : u) : u t
thenmap ~(f:u -> v) (T x)
isT (f x) : v t
. As a result,map
is often thought of as applyingf
"in"T
.The function
map
is the mapping of arrows, taking every arrow'a -> 'b
to an arrow'a t -> 'b t
.
val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
map2 ~f x y
isreturn f <*> x <*> y
, i.e.,f
"lifted" in tot
and then applied to bothx
andy
.
val both : 'a t -> 'b t -> ('a * 'b) t
both (F a) (F b)
isF (a, b)
, i.e., it is the product ofa
andb
inF
module Let_bind : sig ... end
Binding operators for use with the OCaml 4.08 extension. See the OCaml docs on binding operators for more information.