@ -7,8 +7,41 @@
(* * Global namespace intended to be opened in each source file *)
include module type of NS0
module Monad = Monad
(* * Support for [@@deriving compare, equal, hash, sexp] on builtin types *)
include module type of Ppx_compare_lib . Builtin
module Hash = Ppx_hash_lib . Std . Hash
include module type of Hash . Builtin
module Sexp = Sexplib . Sexp
include module type of Ppx_sexp_conv_lib . Conv
(* * Comparison *)
val min : int -> int -> int
val max : int -> int -> int
external ( = ) : int -> int -> bool = " %equal "
external ( < > ) : int -> int -> bool = " %notequal "
external ( < ) : int -> int -> bool = " %lessthan "
external ( > ) : int -> int -> bool = " %greaterthan "
external ( < = ) : int -> int -> bool = " %lessequal "
external ( > = ) : int -> int -> bool = " %greaterequal "
external compare : int -> int -> int = " %compare "
external equal : int -> int -> bool = " %equal "
(* * Polymorphic comparison and hashing *)
module Poly : sig
external ( = ) : ' a -> ' a -> bool = " %equal "
external ( < > ) : ' a -> ' a -> bool = " %notequal "
external ( < ) : ' a -> ' a -> bool = " %lessthan "
external ( > ) : ' a -> ' a -> bool = " %greaterthan "
external ( < = ) : ' a -> ' a -> bool = " %lessequal "
external ( > = ) : ' a -> ' a -> bool = " %greaterequal "
external compare : ' a -> ' a -> int = " %compare "
external equal : ' a -> ' a -> bool = " %equal "
val min : ' a -> ' a -> ' a
val max : ' a -> ' a -> ' a
val hash : ' a -> int
end
(* * Function combinators *)
@ -36,136 +69,149 @@ val ( <$ ) : ('a -> unit) -> 'a -> 'a
(* * Apply and ignore function: [f <$ x] is exactly equivalent to [f x ; x].
Left associative . * )
(* * Failure s *)
(* * Tuple operation s *)
exception Replay of exn * Printexc . raw_backtrace * Sexp . t
exception Unimplemented of string
val fst3 : ' a * _ * _ -> ' a
(* * First projection from a triple. *)
val fail : ( ' a , unit -> _ ) fmt -> ' a
(* * Emit a message at the current indentation level, and raise a [Failure]
exception indicating a fatal error . * )
val snd3 : _ * ' b * _ -> ' b
(* * Second projection from a triple. *)
val todo : ( ' a , unit -> _ ) fmt -> ' a
(* * Raise an [Unimplemented] exception indicating that an input is valid but
not handled by the current implementation . * )
val trd3 : _ * _ * ' c -> ' c
(* * Third projection from a triple. *)
val warn : ( ' a , unit -> unit ) fmt -> ' a
(* * Issue a warning for a survivable problem. *)
(* * Pretty-printing *)
(* * Assertions *)
(* * Pretty-printer for argument type. *)
type ' a pp = Format . formatter -> ' a -> unit
val assertf : bool -> ( ' a , unit -> unit ) fmt -> ' a
(* * Raise an [Failure] exception if the bool argument is false, indicating
that the expected condition was not satisfied . * )
(* * Format strings. *)
type ( ' a , ' b ) fmt = ( ' a , Format . formatter , unit , ' b ) format4
val checkf : bool -> ( ' a , unit -> bool ) fmt -> ' a
(* * As [assertf] but returns the argument bool. *)
(* * Monadic syntax *)
val check : ( ' a -> unit ) -> ' a -> ' a
(* * Assert that function does not raise on argument, and return argument. *)
module type Applicative_syntax = sig
type ' a t
val violates : ( ' a -> unit ) -> ' a -> _
(* * Assert that function raises on argument. *)
(* * Extensions *)
val ( let + ) : ' a t -> ( ' a -> ' b ) -> ' b t
val ( and + ) : ' a t -> ' b t -> ( ' a * ' b ) t
end
module Invariant : sig
include module type of Core . Invarian t
module type Monad_syntax = sig
type ' a t
exception
Violation of
exn * Printexc . raw_backtrace * Source_code_position . t * Sexp . t
val ( let + ) : ' a t -> ( ' a -> ' b ) -> ' b t
val ( and + ) : ' a t -> ' b t -> ( ' a * ' b ) t
val ( let * ) : ' a t -> ( ' a -> ' b t ) -> ' b t
val ( and * ) : ' a t -> ' b t -> ( ' a * ' b ) t
end
(* * Container s *)
(* * Monad s *)
module Option = Option
include module type of Option . Import
module List = List
module Monad = Monad
module Array : sig
include module type of Array
(* * Data types *)
type ' a t = ' a Array . t [ @@ deriving compare , equal , hash , sexp ]
module Sign = Sign
module Char = Containers . Char
module Int = Int
module Z = Z_ext
module Q = Q_ext
module Float = Float
module String = String
module Import : sig
type ' a array = ' a t [ @@ deriving compare , equal , hash , sexp ]
end
(* * Iterators *)
module Iter = Iter
include module type of Iter . Import
(* * Containers *)
val pp : ( unit , unit ) fmt -> ' a pp -> ' a array pp
type ( ' a , ' b ) continue_or_stop = Continue of ' a | Stop of ' b
val map_endo : ' a t -> f : ( ' a -> ' a ) -> ' a t
(* * Like map, but specialized to require [f] to be an endofunction, which
enables preserving [ = = ] if [ f ] preserves [ = = ] of every element . * )
module Option = Option
include module type of Option . Import
val fold_map_inplace :
' a array -> init : ' s -> f : ( ' s -> ' a -> ' s * ' a ) -> ' s
module Either : sig
type ( ' a , ' b ) t = Left of ' a | Right of ' b
val to_list_rev_map : ' a array -> f : ( ' a -> ' b ) -> ' b list
val left : ' a -> ( ' a , ' b ) t
val right : ' a -> ( ' b , ' a ) t
end
include module type of Array . Import
module List = List
module Array = Array
module IArray = IArray
include module type of IArray . Import
module Set = Set
module Map = Map
module Multiset = Multiset
module Hashtbl = Base . Hashtbl
module Hash_set = Base . Hash_set
module Hash_queue = Core_kernel . Hash_queue
(* * Data types *)
(* * Input / Output *)
module String : sig
include
module type of Core . String
with module Map := Core . String . Map
with module Set := Core . String . Set
module In_channel = Stdio . In_channel
module Out_channel = Stdio . Out_channel
module Map : Map . S with type key = string
module Set : Set . S with type elt = string
end
(* * System interfaces *)
module Int : sig
include module type of Stdlib . Int
module Sys = Sys
module Timer = Timer
include
module type of Core . Int
with module Map := Core . Int . Map
with module Set := Core . Int . Set
module Filename : sig
include module type of Filename
module Map : Map . S with type key = int
module Set : Set . S with type elt = int
val realpath : string -> string
end
module Q : sig
include module type of struct
include Q
end
(* * Invariants *)
module Invariant : sig
exception
Violation of exn * Printexc . raw_backtrace * Lexing . position * Sexp . t
val of_z : Z . t -> t
val compare : t -> t -> int
val hash : t -> int
val hash_fold_t : t Hash . folder
val t_of_sexp : Sexp . t -> t
val sexp_of_t : t -> Sexp . t
val pp : t pp
val pow : t -> int -> t
end
val invariant :
Lexing . position -> ' a -> ( ' a -> Sexp . t ) -> ( unit -> unit ) -> unit
module Z : sig
include module type of struct
include Z
end
module type S = sig
type t
val compare : t -> t -> int
val hash : t -> int
val hash_fold_t : t Hash . folder
val t_of_sexp : Sexp . t -> t
val sexp_of_t : t -> Sexp . t
val pp : t pp
val true _ : t
val false _ : t
val of_bool : bool -> t
val is_true : t -> bool
val is_false : t -> bool
val invariant : t -> unit
end
end
module Timer = Timer
(* * Failures *)
exception Replay of exn * Printexc . raw_backtrace * Sexp . t
exception Unimplemented of string
val fail : ( ' a , unit -> _ ) fmt -> ' a
(* * Emit a message at the current indentation level, and raise a [Failure]
exception indicating a fatal error . * )
val todo : ( ' a , unit -> _ ) fmt -> ' a
(* * Raise an [Unimplemented] exception indicating that an input is valid but
not handled by the current implementation . * )
val warn : ( ' a , unit -> unit ) fmt -> ' a
(* * Issue a warning for a survivable problem. *)
(* * Assertions *)
val assertf : bool -> ( ' a , unit -> unit ) fmt -> ' a
(* * Raise an [Failure] exception if the bool argument is false, indicating
that the expected condition was not satisfied . * )
val checkf : bool -> ( ' a , unit -> bool ) fmt -> ' a
(* * As [assertf] but returns the argument bool. *)
val check : ( ' a -> unit ) -> ' a -> ' a
(* * Assert that function does not raise on argument, and return argument. *)
val violates : ( ' a -> unit ) -> ' a -> _
(* * Assert that function raises on argument. *)
(* *)
module With_return = Base . With_return