package alba

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

Result monad

Parameters

Signature

include Module_types.MONAD with type 'a t = ('a, Error.t) result
type 'a t = ('a, Error.t) result

The type of the monad containing values of type 'a

val return : 'a -> 'a t

return a makes a monadic container containing the value a.

val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

m >>= f extracts the value a from the monadic container m and returns f a.

val (>=>) : ('a -> 'b t) -> ('b -> 'c t) -> 'a -> 'c t

f >=> g composition of the two monadic functions f and g.

f >=> g is equivalent to fun a -> f a >>= g.

val map : ('a -> 'b) -> 'a t -> 'b t

map f m maps the values in the monadic container m with the function f.

val join : 'a t t -> 'a t

Remove one level of container. join m is equivalent to mm >>= fun m -> m.

val (<*>) : ('a -> 'b) t -> 'a t -> 'b t

f <*> m applies the function contained in f to the content of the monadic container m and injects the result into a new monadic container.

type error = Error.t
val throw : error -> 'a t
val catch : 'a t -> (error -> 'a t) -> 'a t
val continue : 'a t -> ('a -> 'z) -> (error -> 'z) -> 'z
OCaml

Innovation. Community. Security.