You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.9 KiB
69 lines
1.9 KiB
(*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*)
|
|
|
|
module Poly = struct
|
|
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"
|
|
|
|
let min x y = if x <= y then x else y
|
|
let max x y = if x >= y then x else y
|
|
end
|
|
|
|
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"
|
|
|
|
let compare (a : int) b =
|
|
let int_of_bool (b : bool) = (Obj.magic b : int) in
|
|
int_of_bool (a > b) - int_of_bool (a < b)
|
|
|
|
external equal : int -> int -> bool = "%equal"
|
|
|
|
let min x y = if x <= y then x else y
|
|
let max x y = if x >= y then x else y
|
|
|
|
(** Pretty-printer for argument type. *)
|
|
type 'a pp = Format.formatter -> 'a -> unit
|
|
|
|
(** Format strings. *)
|
|
type ('a, 'b) fmt = ('a, 'b) Trace.fmt
|
|
|
|
module Hash = Ppx_hash_lib.Std.Hash
|
|
module Sexp = Sexplib.Sexp
|
|
|
|
module type Applicative_syntax = sig
|
|
type 'a t
|
|
|
|
val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t
|
|
val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t
|
|
end
|
|
|
|
module type Monad_syntax = sig
|
|
include Applicative_syntax
|
|
|
|
val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
|
|
val ( and* ) : 'a t -> 'b t -> ('a * 'b) t
|
|
end
|
|
|
|
module type OrderedType = sig
|
|
type t
|
|
|
|
val compare : t -> t -> int
|
|
val sexp_of_t : t -> Sexp.t
|
|
end
|
|
|
|
exception Duplicate
|