CCEither
Either Monad
Module that is compatible with Either form OCaml 4.12 but can be use with any ocaml version compatible with container
val left : 'a -> ('a, 'b) t
left l
is Left l
val right : 'b -> ('a, 'b) t
right r
is Right r
val is_left : ('a, 'b) t -> bool
is_left x
checks if x = Left _
val is_right : ('a, 'b) t -> bool
is_right x
checks if x = Right _
val find_left : ('a, 'b) t -> 'a option
find_left x
returns l
if x = Left l
and None
otherwise.
val find_right : ('a, 'b) t -> 'b option
find_right x
returns r
if x = Left r
and None
otherwise.
Map using left
or right
.
val fold : left:('a -> 'c) -> right:('b -> 'c) -> ('a, 'b) t -> 'c
Fold using left
or right
.
val iter : left:('a -> unit) -> right:('b -> unit) -> ('a, 'b) t -> unit
Iter using left
or right
.
val for_all : left:('a -> bool) -> right:('b -> bool) -> ('a, 'b) t -> bool
Check some property on Left
or Right
variant.