module Lazy_deferred: Lazy_deferred
type 'a
t
val create : (unit -> 'a Deferred.t) -> 'a t
create f
creates a new lazy deferred that will call f
when it is forced.
val force : 'a t -> ('a, exn) Core.Std.Result.t Deferred.t
force t
forces evaluation of t
and returns a deferred that becomes determined
when the deferred computation becomes determined or raises.
val force_exn : 'a t -> 'a Deferred.t
val wait : 'a t -> ('a, exn) Core.Std.Result.t Deferred.t
wait t
waits for t
to be forced. If no one ever calls force t
, wait
will wait
forever.
val wait_exn : 'a t -> 'a Deferred.t
include Monad
bind t f
in the lazy-deferred monad creates a computation that, when forced, will
force t
, apply f
to the result, and then force the result of that.
val bind' : 'a t -> ('a -> 'b Deferred.t) -> 'b t
bind'
differs from bind
in that the supplied function produces an 'a Deferred.t
rather than an 'a t
.
val follow : 'a t -> ('a -> 'b Deferred.t) -> 'b t
follow t f
returns a new lazy deferred almost like bind'
with the notable
difference that its computation will start as soon as the deferred it is following
becomes determined
. Since the resulting deferred depends on the 'a
value computed
by t
forcing the resulting of follow
will force the compuation of t
.
Read-only operations.
val peek : 'a t -> ('a, exn) Core.Std.Result.t option
peek t = Deferred.peek (wait t)
val peek_exn : 'a t -> 'a option
val is_determined : 'a t -> bool
val is_forced : 'a t -> bool