Module Prime

Primitives.

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