From b17f55b1d103dd53483d76f669eeee222088622e Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 22 Apr 2016 22:07:06 +0200 Subject: [PATCH] add monomorphic signatures in `CCInt` and `CCFloat` --- src/core/CCFloat.ml | 10 ++++++++++ src/core/CCFloat.mli | 25 +++++++++++++++++++++++++ src/core/CCInt.ml | 12 ++++++++++++ src/core/CCInt.mli | 31 +++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/src/core/CCFloat.ml b/src/core/CCFloat.ml index 6e4a5b56..2fbbe071 100644 --- a/src/core/CCFloat.ml +++ b/src/core/CCFloat.ml @@ -74,3 +74,13 @@ let random_range i j st = i +. random (j-.i) st let equal_precision ~epsilon a b = abs_float (a-.b) < epsilon let classify = Pervasives.classify_float + +module Infix = struct + let (=) = Pervasives.(=) + let (<>) = Pervasives.(<>) + let (<) = Pervasives.(<) + let (>) = Pervasives.(>) + let (<=) = Pervasives.(<=) + let (>=) = Pervasives.(>=) +end +include Infix diff --git a/src/core/CCFloat.mli b/src/core/CCFloat.mli index 4fa7f9ab..f206aec7 100644 --- a/src/core/CCFloat.mli +++ b/src/core/CCFloat.mli @@ -76,3 +76,28 @@ val equal_precision : epsilon:t -> t -> t -> bool (** Equality with allowed error up to a non negative epsilon value *) val classify : float -> fpclass + +(** {2 Infix Operators} + + @since NEXT_RELEASE *) +module Infix : sig + val (=) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (<>) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (<) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (>) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (<=) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (>=) : t -> t -> bool + (** @since NEXT_RELEASE *) +end + +include module type of Infix diff --git a/src/core/CCInt.ml b/src/core/CCInt.ml index 506ab79f..ba1d82a2 100644 --- a/src/core/CCInt.ml +++ b/src/core/CCInt.ml @@ -53,3 +53,15 @@ let to_string = string_of_int let of_string s = try Some (int_of_string s) with _ -> None + +module Infix = struct + let (=) = Pervasives.(=) + let (<>) = Pervasives.(<>) + let (<) = Pervasives.(<) + let (>) = Pervasives.(>) + let (<=) = Pervasives.(<=) + let (>=) = Pervasives.(>=) +end +include Infix +let min = min +let max = max diff --git a/src/core/CCInt.mli b/src/core/CCInt.mli index a07240c6..d5e68952 100644 --- a/src/core/CCInt.mli +++ b/src/core/CCInt.mli @@ -39,3 +39,34 @@ val to_string : t -> string val of_string : string -> t option (** @since 0.13 *) + +val min : t -> t -> t +(** @since NEXT_RELEASE *) + +val max : t -> t -> t +(** @since NEXT_RELEASE *) + +(** {2 Infix Operators} + + @since NEXT_RELEASE *) +module Infix : sig + val (=) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (<>) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (<) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (>) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (<=) : t -> t -> bool + (** @since NEXT_RELEASE *) + + val (>=) : t -> t -> bool + (** @since NEXT_RELEASE *) +end + +include module type of Infix