Skip to content

Commit 931b28e

Browse files
committed
CCEither(cleanup): conditionnally use the Either module
Include the Either module when available (ocaml >= 4.12)
1 parent 5a3c7c7 commit 931b28e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/core/CCEither.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ type 'a equal = 'a -> 'a -> bool
55
type 'a ord = 'a -> 'a -> int
66
type 'a printer = Format.formatter -> 'a -> unit
77

8+
[@@@ifge 4.12]
9+
10+
include Either
11+
12+
[@@@else_]
13+
814
(** {2 Basics} *)
915

1016
type ('a, 'b) t = ('a, 'b) Either.t =
@@ -62,6 +68,8 @@ let compare ~left ~right e1 e2 =
6268
| Left l1, Left l2 -> left l1 l2
6369
| Right r1, Right r2 -> right r1 r2
6470

71+
[@@@endif]
72+
6573
(** {2 IO} *)
6674

6775
let pp ~left ~right fmt = function

src/core/CCEither.mli

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ type 'a equal = 'a -> 'a -> bool
1313
type 'a ord = 'a -> 'a -> int
1414
type 'a printer = Format.formatter -> 'a -> unit
1515

16+
[@@@ifge 4.12]
17+
18+
include module type of Either
19+
(** @inline *)
20+
21+
[@@@else_]
22+
1623
(** {2 Basics} *)
1724

1825
type ('a, 'b) t = ('a, 'b) Either.t =
@@ -70,6 +77,8 @@ val compare :
7077
('a, 'b) t ->
7178
int
7279

80+
[@@@endif]
81+
7382
(** {2 IO} *)
7483

7584
val pp : left:'a printer -> right:'b printer -> ('a, 'b) t printer

0 commit comments

Comments
 (0)