package linksem

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a error =
  1. | Success of 'a
  2. | Fail of string

error is a type used to represent potentially failing computations. Success * marks a successful completion of a computation, whilst Fail err marks a failure, * with err as the reason.

val return : 'a -> 'a error

return is the monadic lifting function for error, representing a successful * computation.

val with_success : 'a error -> 'b -> ('a -> 'b) -> 'b
val fail : string -> 'a error

fail err represents a failing computation, with error message err.

val bind : 'a error -> ('a -> 'b error) -> 'b error

(>>=) is the monadic binding function for error.

as_maybe e drops an error value into a maybe value, throwing away * error information.

val as_maybe : 'a error -> 'a option
val of_maybe : string -> 'a option -> 'a error
val repeatM'' : Nat_big_num.num -> 'a error -> 'a list error -> 'a list error

repeatM count action fails if action is a failing computation, or * successfully produces a list count elements long, where each element is * the value successfully returned by action.

val repeatM : Nat_big_num.num -> 'a error -> 'a list error
val repeatM' : Nat_big_num.num -> 'b -> ('b -> ('a * 'b) error) -> ('a list * 'b) error

repeatM' count seed action is a variant of repeatM that acts like repeatM * apart from any successful result returns a tuple whose second component is seed * and whose first component is the same as would be returned by repeatM.

val mapM' : ('a -> 'b error) -> 'a list -> 'b list error -> 'b list error

mapM f xs maps f across xs, failing if f fails on any element of xs.

val mapM : ('a -> 'b error) -> 'a list -> 'b list error
val foldM : ('a -> 'b -> 'a error) -> 'a -> 'b list -> 'a error

foldM f e xs performs a monadic right fold of f across xs using e * as the base case. Fails if any application of f fails.

val string_of_error : 'a Show.show_class -> 'a error -> string

string_of_error err produces a string representation of err.

val instance_Show_Show_Error_error_dict : 'a Show.show_class -> 'a error Show.show_class
OCaml

Innovation. Community. Security.