package preface

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

Implementation for Result.t.

Result.t is like Either.t but it exist for semantic reasons. (Left and Right are not very specific on what are the valid and the invalid branch).

Type

type ('a, 'b) t = ('a, 'b) result =
  1. | Ok of 'a
  2. | Error of 'b

Implementation

Bifunctor

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

Delayed implementation

By setting the error type of Result.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 = ('a, T.t) Bifunctor.t

Applicative

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

Monad

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

Foldable

Addtional functions

Additional functions to facilitate practical work with Result.t.

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

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

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

Equality between Result.t.

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

Formatter for pretty-printing for Result.t.

OCaml

Innovation. Community. Security.