package linksem

  1. Overview
  2. Docs
Module type
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 -> 'a0 error

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

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

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

val bind : 'a error -> ('c -> '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 -> 'a0 option
val of_maybe : string -> 'a option -> 'a0 error
val repeatM'' : Nat_big_num.num -> 'a error -> 'a0 list error -> 'a0 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 -> 'a0 list error
val repeatM' : Nat_big_num.num -> 'b -> ('b0 -> ('a * 'b1) error) -> ('a0 list * 'b2) 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) -> 'c list -> 'b0 list error -> 'b1 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 -> 'b0 list error
val foldM : ('a -> 'b -> 'a0 error) -> 'a1 -> 'c list -> 'a2 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 -> 'b error -> string

string_of_error err produces a string representation of err.

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