Module Order.Equality

Module for the Ordering function type. Includes implementations for common data types.

type 'a t = 'a equality

The type of equality testing functions.

val unit : unit equality

Equality testing function for values of type unit.

val bool : bool equality

Equality testing function for values of type bool.

val char : char equality

Equality testing function for values of type char.

val int : int equality

Equality testing function for values of type int.

val int32 : int32 equality

Equality testing function for values of type int32.

val int64 : int64 equality

Equality testing function for values of type int64.

val float : float equality

Equality testing function for values of type float.

val string : string equality

Equality testing function for values of type string.

val bytes : bytes equality

Equality testing function for values of type bytes.

val list : 'a equality -> 'a list equality

Equality testing function for values of type list.

val array : 'a equality -> 'a array equality

Equality testing function for values of type array.

val option : 'a equality -> 'a option equality

Equality testing function for values of type option.

val result : 'a equality -> 'b equality -> ('a'b) Result.result equality

Equality testing function for values of type result.

val ref : 'a equality -> 'a Pervasives.ref equality

Equality testing function for values of type ref.

val pair : 'a equality -> 'b equality -> ('a * 'b) equality

Equality testing function for pairs of type 'a * 'b.

val triple : 'a equality -> 'b equality -> 'c equality -> ('a * 'b * 'c) equality

Equality testing function for triples of type 'a * 'b * 'c.

val by : ('a -> 'b) -> 'b equality -> 'a equality

by f equal is a comparator that applies the projection function f before testing the equality with equal.

This function can be used to, for example, extract fields or apply transformations on values before comparing them. The provided equal function will be applied to the values produced by f.

Examples

let l1 = [0; 1; 2; 3] in
let l2 = [4; 5; 6; 7] in
let equal_by_length = Equality.(by List.length int) in
assert (equal_by_length l1 l2))