Module Util


module Util: sig .. end
Miscellaneous utility types and values.

exception Bug
Indicates a bug in the library. This exception is raised in cases that violate library or language invariants.
val id : 'a -> 'a
The identity function
val const : 'a -> 'b -> 'a
The K combinator
val (%) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b
Function composition
val ($) : ('a -> 'b) -> 'a -> 'b
Function application
val (^$) : ('a -> 'b) -> 'a -> 'b
Function application, right associative
val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c
Flip the arguments of a function

type ('a, 'b) either =
| Left of 'a (*Miscellaneous utility types and values.*)
| Right of 'b (*Miscellaneous utility types and values.*)
Anonymous sum types
val either : ('a, 'b) either -> ('a -> 'c) -> ('b -> 'c) -> 'c
val maybe : 'a option -> (unit -> 'b) -> ('a -> 'b) -> 'b
Projection from option
val oapply : ('a -> 'b) -> 'a option -> 'b option
Application inside option
val option_of_exn : (unit -> 'a) -> 'a option
Map exceptions to None
val unwind_protect : (unit -> 'a) -> (unit -> 'b) -> 'a
Call a thunk and then run cleanup code. Util.unwind_protect thunk after calls thunk. If thunk returns a value, it calls after and then returns the value. If thunk raises, it calls after and then re-raises.
val while_none : (unit -> 'a option) -> (unit -> 'b) -> 'a
Loop until a thunk returns Some v. Util.while_none cond body calls cond. If cond returns Some v then it returns v; if cond returns None, it calls body and then tries iterates.
val find' : ('a -> bool) -> 'a list -> 'a option
Find an element in a list. Like List.find', but returns an option rather than raising.

type protector = {
   protector : 'a. (unit -> 'a) -> 'a;
}
Record type for universally quantified around advice.