Module CCEither
Either Monad
Module that is compatible with Either form OCaml 4.12 but can be use with any ocaml version compatible with container
- since
- 3.2
type 'a iter
= ('a -> unit) -> unit
type 'a equal
= 'a -> 'a -> bool
type 'a ord
= 'a -> 'a -> int
type 'a printer
= Stdlib.Format.formatter -> 'a -> unit
Basics
include module type of CCShimsEither_
val left : 'a -> ('a, 'b) t
left l
isLeft l
val right : 'b -> ('a, 'b) t
right r
isRight r
val is_left : ('a, 'b) t -> bool
is_left x
checks ifx = Left _
val is_right : ('a, 'b) t -> bool
is_right x
checks ifx = Right _
val find_left : ('a, 'b) t -> 'a option
find_left x
returnsl
ifx = Left l
andNone
otherwise.
val find_right : ('a, 'b) t -> 'b option
find_right x
returnsr
ifx = Left r
andNone
otherwise.
val map : left:('a1 -> 'a2) -> right:('b1 -> 'b2) -> ('a1, 'b1) t -> ('a2, 'b2) t
Map using
left
orright
.
val fold : left:('a -> 'c) -> right:('b -> 'c) -> ('a, 'b) t -> 'c
Fold using
left
orright
.
val iter : left:('a -> unit) -> right:('b -> unit) -> ('a, 'b) t -> unit
Iter using
left
orright
.
val for_all : left:('a -> bool) -> right:('b -> bool) -> ('a, 'b) t -> bool
Check some property on
Left
orRight
variant.