diff --git a/src/core/CCString.ml b/src/core/CCString.ml index 157bbfed..8f93c036 100644 --- a/src/core/CCString.ml +++ b/src/core/CCString.ml @@ -3,6 +3,10 @@ (** {1 Basic String Utils} *) +(*$inject + open CCShims_.Stdlib +*) + open CCShims_ type 'a iter = ('a -> unit) -> unit @@ -1053,6 +1057,22 @@ let pp_buf buf s = let pp fmt s = Format.fprintf fmt "\"%s\"" s +module Infix = struct + let (=) = equal + let (<>) a b = not (equal a b) + let (>) : t -> t -> bool = CCShims_.Stdlib.(>) + let (>=) : t -> t -> bool = CCShims_.Stdlib.(>=) + let (<) : t -> t -> bool = CCShims_.Stdlib.(<) + let (<=) : t -> t -> bool = CCShims_.Stdlib.(<=) +end + +include Infix + +(*$T + "ab" < "abc" + "123" < "14" + *) + (* test consistency of interfaces *) (*$inject module type L = module type of CCString diff --git a/src/core/CCString.mli b/src/core/CCString.mli index f92d8a9c..79eb693c 100644 --- a/src/core/CCString.mli +++ b/src/core/CCString.mli @@ -417,3 +417,29 @@ val edit_distance : ?cutoff:int -> string -> string -> int and on the result. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 (use cutoff of 3). *) + +(** {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/CCStringLabels.mli b/src/core/CCStringLabels.mli index 72e4536e..b2919e68 100644 --- a/src/core/CCStringLabels.mli +++ b/src/core/CCStringLabels.mli @@ -436,3 +436,29 @@ val edit_distance : ?cutoff:int -> string -> string -> int and on the result. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 (use cutoff of 3). *) + +(** {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