package yocaml

  1. Overview
  2. Docs

Module Yocaml.TrySource

A specialised version of Result (with Error.t as Error part). Try is very useful for producing sequential validations, where as soon as a step produces an error, the computation sequence is interrupted.

Type

Sourcetype 'a t = ('a, Error.t) Preface.Result.t

A specialised version of Result.

Constructors

Production of valid (Ok) or invalid (Error) values.

Sourceval ok : 'a -> 'a t

Produces a valid value.

Sourceval error : Error.t -> 'a t

Produces an invalid value.

Conversions

Sourceval to_validate : 'a t -> ('a, Error.t Preface.Nonempty_list.t) Preface.Validation.t

Produces a Validate from a Try.

Sourceval from_validate : ('a, Error.t Preface.Nonempty_list.t) Preface.Validation.t -> 'a t

Produces a Try from a Validate.

Helpers

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

Pretty-printers for Try.t.

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

Equality betweens Try.t.

Implementations

Some implementations of some abstractions offered by Preface.

module Functor : Preface.Specs.FUNCTOR with type 'a t = 'a t

Try is a Functor that (logically) implements map.

module Applicative : Preface.Specs.Traversable.API_OVER_APPLICATIVE with type 'a t = 'a t

Try is an Applicative that (logically) implements apply and pure.

module Monad : Preface.Specs.Traversable.API_OVER_MONAD with type 'a t = 'a t

Try is also a Monad that (logically) implements bind and return.

Infix and Syntax operators

Sourcemodule Infix : sig ... end
Sourcemodule Syntax : sig ... end
include module type of Infix with type 'a t := 'a t
include Preface.Specs.Applicative.INFIX with type 'a t := 'a t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
val (<**>) : 'a t -> ('a -> 'b) t -> 'b t
val (*>) : unit t -> 'a t -> 'a t
val (<*) : 'a t -> unit t -> 'a t
include Preface.Specs.Monad.INFIX with type 'a t := 'a t
val (=|<) : ('a -> 'b) -> 'a t -> 'b t
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
val (=<<) : ('a -> 'b t) -> 'a t -> 'b t
val (>=>) : ('a -> 'b t) -> ('b -> 'c t) -> 'a -> 'c t
val (<=<) : ('b -> 'c t) -> ('a -> 'b t) -> 'a -> 'c t
val (>>) : unit t -> 'b t -> 'b t
val (<<) : 'a t -> unit t -> 'a t
val (<$>) : ('a -> 'b) -> 'a t -> 'b t
val (<&>) : 'a t -> ('a -> 'b) -> 'b t
val (<$) : 'a -> 'b t -> 'a t
val ($>) : 'a t -> 'b -> 'b t
include module type of Syntax with type 'a t := 'a t
include Preface.Specs.Applicative.SYNTAX with type 'a t := 'a t
val (and+) : 'a t -> 'b t -> ('a * 'b) t
include Preface.Specs.Monad.SYNTAX with type 'a t := 'a t
val (let*) : 'a t -> ('a -> 'b t) -> 'b t
val (let+) : 'a t -> ('a -> 'b) -> 'b t