Module Unprime

Pervasives.

include module type of Prime

The Empty Type

type counit

A type which is uninhabited by well-founded code. This is equivalent to a variant type with no constructors, though syntax forbids naming or defining such types.

val absurd : counit -> 'a

Computations in the scope of a variable x : counit can be assumed dead, and thus be shortcut as absurd x. This is the analogue of pattern-matching a variant with no constructors.

Combinators

val ident : 'a -> 'a

The I combinator: ident x is x.

val konst : 'a -> 'b -> 'a

The K combinator: konst x y is x.

val (%) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c

Function composition: (g % f) x is g (f x).

val (%>) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c

Reversed function composition: (f %> g) x is g (f x).

Currying

val curry : (('a * 'b) -> 'c) -> 'a -> 'b -> 'c

curry f x y is f (x, y).

val uncurry : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

uncurry f (x, y) is f x y.

Exceptions

val finally : (unit -> unit) -> (unit -> 'a) -> 'a

Option Operators

val (|?>.) : 'a option -> ('a -> 'b) -> 'b option

An operator variant of Option.map.

val (|?>..) : 'a option -> ('a -> 'b -> 'b) -> 'b -> 'b

An operator variant of Option.fold.

val (|?>!) : 'a option -> ('a -> unit) -> unit

An operator variant of Option.iter.

val (|?>=) : 'a option -> ('a -> 'b option) -> 'b option

None |?>= f is None and Some x |?>= f is f x. This is the bind operator of the maybe monad.

List Operators

val (|@>.) : 'a list -> ('a -> 'b) -> 'b list

An operator variant of List.map.

val (|@>..) : 'a list -> ('a -> 'b -> 'b) -> 'b -> 'b

An operator variant of List.fold.

val (|@>!) : 'a list -> ('a -> unit) -> unit

An operator variant of List.iter.

val (|@>=) : 'a list -> ('a -> 'b list) -> 'b list

[x₁; …; xₙ] |@>= f computes f x₁ @ ⋯ @ f xₙ. This is the bind operator of the list monad.