package preface

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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) Preface_core.Shims.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 : (Format.formatter -> 'a -> unit) -> (Format.formatter -> 'b -> unit) -> Format.formatter -> ('a, 'b) t -> unit

Formatter for pretty-printing for Either.t.

OCaml

Innovation. Community. Security.