Fn structure
May 20, 2026 ยท View on GitHub
The Fn structure provides combinators for working with function values,
including application, composition, currying, and fixpoint operators.
Synopsis
val id : 'a -> 'a val const : 'a -> 'b -> 'a val apply : ('a -> 'b) * 'a -> 'b val o : ('b -> 'c) * ('a -> 'b) -> 'a -> 'c val curry : ('a * 'b -> 'c) -> 'a -> 'b -> 'c val uncurry : ('a -> 'b -> 'c) -> 'a * 'b -> 'c val flip : ('a * 'b -> 'c) -> 'b * 'a -> 'c val repeat : int -> ('a -> 'a) -> 'a -> 'a val equal : 'a -> 'a -> bool val notEqual : 'a -> 'a -> bool
id
id x returns the value x. (id is the polymorphic identity function.)
const
const x y returns the value x.
apply
apply (f, x) applies the function f to x. Thus, it is equivalent to f x.
o
f o g is the function composition of f and g. Thus, (f o g) a
is equivalent to f (g a). This function is the same as the global
o operator and is also part of the General structure.
curry
curry f x y is equivalent to f (x, y); i.e., curry f transforms
the binary function f into curried form.
uncurry
ucurry f (x, y) is equivalent to f x y; i.e., uncurry f transforms the curried
function f into a binary function. This function is the inverse of
curry.
flip
flip f (x, y) is equivalent to f (y, x); i.e., flip f flips the argument order
of the binary function f.
repeat
repeat n f returns the n-fold composition of f. If n is zero, then
repeat n f returns the identity function. If n is negative, then
it raises the exception Domain.
equal
equal a b returns whether a is equal to b. It is a curried version of the
polymorphic equality function (=).
notEqual
notEqual a b returns whether a is not equal to b. It is a curried version of
the polymorphic inequality function (<>).