package MlFront_Thunk

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

Parameter Make.M

type 'a t

The type 'a t is the set of (future) promises for values of type 'a.

type 'a resolver

The type 'a t is the type of resolvers for pending promises of a value of type 'a.

type resolved_promise_state

The type resolved_promise_state is the set of states a Resolved promise can be in. The set will be either type 'a in t or a reversed monadic transformation of type 'a which you need to unwrap. In other words, the resolution has no knowledge of the transformations of the monad (nor should it!).

include MlFront_Thunk.BuildConstraints.MONAD with type 'a t := 'a t
include MlFront_Thunk.BuildConstraints.FUNCTOR with type 'a t := 'a t
include MlFront_Thunk.BuildConstraints.APPLICATIVE with type 'a t := 'a t
include MlFront_Thunk.BuildConstraints.FUNCTOR with type 'a t := 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val pure : 'a -> 'a t
val apply : ('a -> 'b) t -> 'a t -> 'b t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val make_promise : unit -> 'a t * 'a resolver

make_promise () is a new promise and resolver. The promise is pending.

val return : 'a -> 'a t

return x is a new promise that is already resolved with value x.

promise_state p is the state of the promise

val resolve : 'a resolver -> 'a -> unit

resolve r x resolves the promise p associated with r with value x, meaning that state p will become Resolved x. Requires: p is pending.

val reject : 'a resolver -> exn -> unit

reject r x rejects the promise p associated with r with exception x, meaning that state p will become Rejected x. Requires: p is pending.

val parallel : 'a t list -> 'a list t

parallel ps is a promise that resolves when all the promises in ps resolve, or rejects when any promise in ps rejects. The order of the resolved values is the same as the order of the promises in ps.