package preface

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

Module Preface_stdlib.TrySource

Implementation for Try.t.

Try.t is a biased version of Result with the error fixed as an exception.

Type

Sourcetype 'a t = ('a, exn) result

Implementation

Functor

module Functor : Preface_specs.FUNCTOR with type 'a t = 'a t

Alt

module Alt : Preface_specs.ALT with type 'a t = 'a t

Applicative

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

Selective

module Selective : Preface_specs.SELECTIVE with type 'a t = 'a t

Monad

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

Foldable

module Foldable : Preface_specs.FOLDABLE with type 'a t = 'a t

Invariant

module Invariant : Preface_specs.INVARIANT with type 'a t = 'a t

Additional functions

Additional functions to facilitate practical work with Try.t.

Sourceval pure : 'a -> 'a t

Create a value from 'a to 'a t.

Sourceval ok : 'a -> 'a t

Wrap a value into Ok.

Sourceval error : exn -> 'a t

Wrap an exception into Error.

Sourceval capture : (unit -> 'a) -> 'a t

capture f perform f and wrap the result into a t if the execution of f raise no exception, the result will be Ok result else, the caught exception if wrapped into Error exn.

Sourceval case : ('a -> 'b) -> (exn -> 'b) -> 'a t -> 'b

case f g x apply f if x is Ok, g if x is Error.

Sourceval to_validation : 'a t -> ('a, exn Nonempty_list.t) Validation.t

Project a Try into a Validation.

Sourceval equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

Equality between Try.t.

Sourceval pp : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit

Formatter for pretty-printing for Try.t.

OCaml

Innovation. Community. Security.