Module Eventually

type 'a eventually

A value of type 'a eventually is a time-bounded computation that, when run subject to a timer, may either

  • return a value of type 'a,
  • or timeout.

y : 'a eventually is said to converge if run t y terminates for all finite timers t.

type 'a now =
  1. | Timeout
  2. | Success of 'a

The result of running a time-bounded computation, which is either

  • a timeout Timeout,
  • or a returned value Success x.
val tick : int -> unit eventually

Advance the current timer by n ticks, or timeout if the timer is already finished.

Once the computation is run, raises Invalid_argument if n is negative.

val return : 'a -> 'a eventually

Return a pure value.

val sequence : 'a eventually -> ('a -> 'b eventually) -> 'b eventually

Sequence two computations, binding a value dependency between them.

val forkjoin : 'a eventually -> 'b eventually -> ('a * 'b) eventually

Simulate the parallel execution of two computations.

val run : Timer.timer -> 'a eventually -> 'a now

Run the computation, subject to a timer. Returns

  • Timeout on timeout,
  • and Success x otherwise.
exception ForeverTimesout

Should be raised if run Timer.forever y returns Timeout, which is impossible.