Module Alg_structs.Applicative
Applicative functors "allow sequencing of functorial computations" (wikipedia) with the limitation that "values computed by subcomputations cannot affect what subsequent computations will take place" (Core docs).
Assume that we've implemented Applicative for some parametertic type 'p t
. Take two values F x : 'a t
and F y : 'b t
and a computation represented by a function F f : ('a -> 'b -> 'c) t
. We can then use the applicative's namesake function S.apply
to sequence this computation "within" type t
:
apply (apply f x) y : 'c t
The "sequencing" of the computation (via application) is even more apparent when we use the infix notation for apply
:
f <*> x <*> y
See Implementations for illustrative examples.
Seed
module type Seed = sig ... end
The
Seed
needed to generate an implementation of Applicative
Interface
module type S = sig ... end
Laws
module Law : functor (A : S) -> sig ... end
Law
notes the laws that should be obeyed by any instantiation of Applicative in the form of predicates that should be true for any arguments of the appropriate type.
Constructors
Module functors for creating implementations of Applicative
Implementations
Implementations for common data structures. See the documentation for each implementation module for an illustrative example.
module Option : S with type 'a t = 'a Stdlib.Option.t
Option
provides sequencing of partial computations. E.g,