Module Lazy

module Lazy: Core_lazy

type 'a t = 'a lazy_t 
include Monad.S
exception Undefined
val force : 'a t -> 'a
force x forces the suspension x and returns its result. If x has already been forced, Lazy.force x returns the same value again without recomputing it. If it raised an exception, the same exception is raised again. Raise Undefined if the forcing of x tries to force x itself recursively.
val force_val : 'a t -> 'a
Like force except that if the computation of x raises an exception, it is unspecified whether force_val x raises the same exception or Undefined.
val from_fun : (unit -> 'a) -> 'a t
from_fun f is the same as lazy (f ()) but slightly more efficient.
val from_val : 'a -> 'a t
from_val v returns an already-forced suspension of v This is for special purposes only and should not be confused with lazy (v).
val is_val : 'a t -> bool
is_val x returns true if x has already been forced and did not raise an exception.
val t_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a t
val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val bin_t : 'a Bin_prot.Type_class.t -> 'a t Bin_prot.Type_class.t
val bin_read_t : 'a Bin_prot.Unsafe_read_c.reader -> 'a t Bin_prot.Read_ml.reader
val bin_read_t_ : 'a Bin_prot.Unsafe_read_c.reader ->
'a t Bin_prot.Unsafe_read_c.reader
val bin_read_t__ : 'a Bin_prot.Unsafe_read_c.reader ->
(int -> 'a t) Bin_prot.Unsafe_read_c.reader
val bin_reader_t : 'a Bin_prot.Type_class.reader -> 'a t Bin_prot.Type_class.reader
val bin_size_t : 'a Bin_prot.Size.sizer -> 'a t Bin_prot.Size.sizer
val bin_write_t : 'a Bin_prot.Unsafe_write_c.writer -> 'a t Bin_prot.Write_ml.writer
val bin_write_t_ : 'a Bin_prot.Unsafe_write_c.writer ->
'a t Bin_prot.Unsafe_write_c.writer
val bin_writer_t : 'a Bin_prot.Type_class.writer -> 'a t Bin_prot.Type_class.writer

force x forces the suspension x and returns its result. If x has already been forced, Lazy.force x returns the same value again without recomputing it. If it raised an exception, the same exception is raised again. Raise Undefined if the forcing of x tries to force x itself recursively.

Like force except that if the computation of x raises an exception, it is unspecified whether force_val x raises the same exception or Undefined.

from_fun f is the same as lazy (f ()) but slightly more efficient.

from_val v returns an already-forced suspension of v This is for special purposes only and should not be confused with lazy (v).

is_val x returns true if x has already been forced and did not raise an exception.