package alg_structs

  1. Overview
  2. Docs

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.


module type Seed = sig ... end

The Seed needed to generate an implementation of Applicative


module type S = sig ... end


module Law (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.


Module functors for creating implementations of Applicative

module Make (B : Seed) : S with type 'a t = 'a B.t


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,

module List : S with type 'a t = 'a Stdlib.List.t

List defines applications that work across all possible combinations of the items in the respective lists. This is often used to model non-determinism.

module Array : S with type 'a t = 'a Stdlib.Array.t

As List but using arrays.


Innovation. Community. Security.