Module Preface_stdlib.Either

Implementation for Either.t.

Either.t is the simplest sum type. In addition to allowing the generic description of sum types, it allows the description of a disjunction, for example to generalise a conditional branching.

Type

type ('a, 'b) t = ('a, 'b) Stdlib.Either.t =
  1. | Left of 'a
  2. | Right of 'b

Implementation

The set of concrete implementations for Either.t.

Bifunctor

module Bifunctor : Preface_specs.BIFUNCTOR with type ('a, 'b) t = ('a, 'b) t

Delayed implementation

By setting the left type of Either.t it is possible to get implementations for abstractions on constructors of type with an arity of 1.

Functor

Alt

module Alt (T : Preface_specs.Types.T0) : Preface_specs.ALT with type 'a t = (T.t, 'a) Bifunctor.t

Applicative

Either.t implements Preface_specs.APPLICATIVE and introduces an interface to define Preface_specs.TRAVERSABLE using Either as an iterable structure.

Selective

Monad

Either.t implements Preface_specs.MONAD and introduces an interface to define Preface_specs.TRAVERSABLE using Either as an iterable structure.

Invariant Functor

Foldable

Additional functions

Additional functions to facilitate practical work with Either.t.

val pure : 'b -> ('a, 'b) t

Create a value from 'b to ('a, 'b) t, a value wrapped in Right.

val equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> ('a, 'b) t -> ('a, 'b) t -> bool

Equality between Either.t.

val pp : (Stdlib.Format.formatter -> 'a -> unit) -> (Stdlib.Format.formatter -> 'b -> unit) -> Stdlib.Format.formatter -> ('a, 'b) t -> unit

Formatter for pretty-printing for Either.t.