package containers

  1. Overview
  2. Docs
A modular, clean and powerful extension of the OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

containers-3.13.tbz
sha256=372df86e2a41e86c959c28a3392eb2ffd89754d1e5af2aaa09537654af57b1da
sha512=7d87d44065612095fa0342a9c95a2c4cfdf73d5af47c6fce24262cf2870c36dee70ebecd056113aa9c1643256bc032c08530f5083061c44602c0da5a132c2d6c

doc/containers/CCEither/index.html

Module CCEitherSource

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
Sourcetype 'a iter = ('a -> unit) -> unit
Sourcetype 'a equal = 'a -> 'a -> bool
Sourcetype 'a ord = 'a -> 'a -> int
Sourcetype 'a printer = Format.formatter -> 'a -> unit

Basics

Sourcetype ('a, 'b) t = ('a, 'b) Either.t =
  1. | Left of 'a
  2. | Right of 'b
Sourceval left : 'a -> ('a, 'b) t

left l is Left l

Sourceval right : 'b -> ('a, 'b) t

right r is Right r

Sourceval is_left : ('a, 'b) t -> bool

is_left x checks if x = Left _

Sourceval is_right : ('a, 'b) t -> bool

is_right x checks if x = Right _

Sourceval find_left : ('a, 'b) t -> 'a option

find_left x returns l if x = Left l and None otherwise.

Sourceval find_right : ('a, 'b) t -> 'b option

find_right x returns r if x = Left r and None otherwise.

Sourceval map_left : ('a1 -> 'a2) -> ('a1, 'b) t -> ('a2, 'b) t

Map of the Left variant.

Sourceval map_right : ('b1 -> 'b2) -> ('a, 'b1) t -> ('a, 'b2) t

Map of the Right variant.

Sourceval map : left:('a1 -> 'a2) -> right:('b1 -> 'b2) -> ('a1, 'b1) t -> ('a2, 'b2) t

Map using left or right.

Sourceval fold : left:('a -> 'c) -> right:('b -> 'c) -> ('a, 'b) t -> 'c

Fold using left or right.

Sourceval iter : left:('a -> unit) -> right:('b -> unit) -> ('a, 'b) t -> unit

Iter using left or right.

Sourceval for_all : left:('a -> bool) -> right:('b -> bool) -> ('a, 'b) t -> bool

Check some property on Left or Right variant.

Sourceval equal : left:('a -> 'a -> bool) -> right:('b -> 'b -> bool) -> ('a, 'b) t -> ('a, 'b) t -> bool
Sourceval compare : left:('a -> 'a -> int) -> right:('b -> 'b -> int) -> ('a, 'b) t -> ('a, 'b) t -> int

IO

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

Pretty printer.

OCaml

Innovation. Community. Security.

On This Page
  1. Basics
  2. IO