mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
CCEither(cleanup): conditionnally use the Either module
Include the Either module when available (ocaml >= 4.12)
This commit is contained in:
parent
5a3c7c7971
commit
931b28ec47
2 changed files with 17 additions and 0 deletions
|
|
@ -5,6 +5,12 @@ type 'a equal = 'a -> 'a -> bool
|
|||
type 'a ord = 'a -> 'a -> int
|
||||
type 'a printer = Format.formatter -> 'a -> unit
|
||||
|
||||
[@@@ifge 4.12]
|
||||
|
||||
include Either
|
||||
|
||||
[@@@else_]
|
||||
|
||||
(** {2 Basics} *)
|
||||
|
||||
type ('a, 'b) t = ('a, 'b) Either.t =
|
||||
|
|
@ -62,6 +68,8 @@ let compare ~left ~right e1 e2 =
|
|||
| Left l1, Left l2 -> left l1 l2
|
||||
| Right r1, Right r2 -> right r1 r2
|
||||
|
||||
[@@@endif]
|
||||
|
||||
(** {2 IO} *)
|
||||
|
||||
let pp ~left ~right fmt = function
|
||||
|
|
|
|||
|
|
@ -13,6 +13,13 @@ type 'a equal = 'a -> 'a -> bool
|
|||
type 'a ord = 'a -> 'a -> int
|
||||
type 'a printer = Format.formatter -> 'a -> unit
|
||||
|
||||
[@@@ifge 4.12]
|
||||
|
||||
include module type of Either
|
||||
(** @inline *)
|
||||
|
||||
[@@@else_]
|
||||
|
||||
(** {2 Basics} *)
|
||||
|
||||
type ('a, 'b) t = ('a, 'b) Either.t =
|
||||
|
|
@ -70,6 +77,8 @@ val compare :
|
|||
('a, 'b) t ->
|
||||
int
|
||||
|
||||
[@@@endif]
|
||||
|
||||
(** {2 IO} *)
|
||||
|
||||
val pp : left:'a printer -> right:'b printer -> ('a, 'b) t printer
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue