package popper

  1. Overview
  2. Docs

Module Popper.ComparatorSource

Types

This module exposes a type 'a t. A value of type a t is used for comparing and pretty printing values of type a.

Sourcetype 'a t

Basic operators

Sourceval make : ('a -> 'a -> int) -> (Format.formatter -> 'a -> unit) -> 'a t

make compare pp constructs a comparator using the given compare to compare value and pp to print them.

Sourceval compare : 'a t -> 'a -> 'a -> int

compare c x y compares x and y using the c comparator.

Sourceval pp : 'a t -> Format.formatter -> 'a -> unit

pp c x prints x using the c comparator.

Primitive comparators

Sourceval int : int t

int is an integer comparator.

Sourceval float : float t

float is a float comparator.

Sourceval bool : bool t

bool is a bool comparator.

Sourceval string : string t

string is a string comparator.

Combinators
Sourceval tuple : 'a t -> 'b t -> ('a * 'b) t

tuple c1 c2 creates a comparator for tuples using the comparators c1 and c2.

Sourceval list : 'a t -> 'a list t

tuple c creates a comparator for lists using the the comparator c.

Sourceval array : 'a t -> 'a array t

array c creates a comparator for arrays using the the comparator c.

Sourceval option : 'a t -> 'a option t

option c creates a comparator for options using the the comparator c.

Sourceval result : ok:'a t -> error:'e t -> ('a, 'e) result t

option ~ok ~error creates a comparator for result values using the the comparators ok and error.

OCaml

Innovation. Community. Security.