diff --git a/src/core/CCFun.cppo.ml b/src/core/CCFun.cppo.ml index c14cdb84..b8927c81 100644 --- a/src/core/CCFun.cppo.ml +++ b/src/core/CCFun.cppo.ml @@ -15,6 +15,16 @@ let (@@) f x = f x #endif +#if OCAML_MAJOR >= 4 && OCAML_MINOR >= 3 + +let opaque_identity = Sys.opaque_identity + +#else + +let opaque_identity x = x + +#endif + let compose f g x = g (f x) let compose_binop f g x y = g (f x) (f y) diff --git a/src/core/CCFun.mli b/src/core/CCFun.mli index 7d731708..6f8a1c0e 100644 --- a/src/core/CCFun.mli +++ b/src/core/CCFun.mli @@ -65,6 +65,12 @@ val finally2 : h:(unit -> _) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c [h ()] is called whether [f x y] rose an exception or not. @since 0.16 *) +val opaque_identity : 'a -> 'a +(** [opaque_identity x] is like [x], but prevents Flambda from using [x]'s + definition for optimizing it (flambda is an optimization/inlining pass + in OCaml >= 4.03). + @since NEXT_RELEASE *) + (** {2 Monad} Functions with a fixed domain are monads in their codomain *) diff --git a/src/core/CCString.cppo.ml b/src/core/CCString.cppo.ml index b476f92f..8a510d4e 100644 --- a/src/core/CCString.cppo.ml +++ b/src/core/CCString.cppo.ml @@ -639,6 +639,26 @@ let exists2 p s1 s2 = try iter2 (fun c1 c2 -> if p c1 c2 then raise MyExit) s1 s2; false with MyExit -> true +(** {2 Ascii functions} *) + +#if OCAML_MAJOR >= 4 && OCAML_MINOR >= 3 + +let capitalize_ascii = String.capitalize_ascii +let uncapitalize_ascii = String.uncapitalize_ascii +let uppercase_ascii = String.uppercase_ascii +let lowercase_ascii = String.lowercase_ascii + +#else + +let capitalize_ascii = String.capitalize +let uncapitalize_ascii = String.uncapitalize +let uppercase_ascii = String.uppercase +let lowercase_ascii = String.lowercase + +#endif + + + let pp buf s = Buffer.add_char buf '"'; Buffer.add_string buf s; diff --git a/src/core/CCString.mli b/src/core/CCString.mli index a61d52fd..edee2895 100644 --- a/src/core/CCString.mli +++ b/src/core/CCString.mli @@ -378,6 +378,24 @@ val exists2 : (char -> char -> bool) -> string -> string -> bool @raise Invalid_argument if the strings have not the same length @since 0.12 *) +(** {2 Ascii functions} + + Those functions are deprecated in {!String} since 4.03, so we provide + a stable alias for them even in older versions *) + +val capitalize_ascii : string -> string +(** See {!String}. @since NEXT_RELEASE *) + +val uncapitalize_ascii : string -> string +(** See {!String}. @since NEXT_RELEASE *) + +val uppercase_ascii : string -> string +(** See {!String}. @since NEXT_RELEASE *) + +val lowercase_ascii : string -> string +(** See {!String}. @since NEXT_RELEASE *) + + (** {2 Splitting} *) module Split : sig