package monads

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

Parameters

module M : Basic2

Signature

include Basic2 with type ('a, 'e) t := ('a, 'e) M.t
val pure : 'a -> ('a, 'e) M.t

pure x creates a computation that results in x.

val zero : unit -> ('a, 'e) M.t

zero () creates a computation that has no result.

val accept : 'a -> ('a, 'e) M.t

accept x accepts x as a result of computation. (Same as pure x.

val reject : unit -> ('a, 'e) M.t

reject () rejects the rest of computation sequence, and terminate the computation with the zero result (Same as zero ()

val guard : bool -> (unit, 'e) M.t

guard cond ensures cond is true in the rest of computation. Otherwise the rest of the computation is rejected.

val on : bool -> (unit, 'e) M.t -> (unit, 'e) M.t

on cond x computes x only iff cond is true

val unless : bool -> (unit, 'e) M.t -> (unit, 'e) M.t

unless cond x computes x unless cond is true.