# Module Std_internal.Lazy

    module Lazy: Core_lazy

    type 'a t = 'a lazy_t

    val typerep_of_t : 'a Typerep_lib.Std.Typerep.t -> 'a t Typerep_lib.Std.Typerep.t

    val typename_of_t : 'a Typerep_lib.Std.Typename.t -> 'a t Typerep_lib.Std.Typename.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.

    module T_unforcing: sig .. end

This type offers a serialization function `sexp_of_t` that won't force its argument.

    module Stable: sig .. end

    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.Read.reader -> 'a t Bin_prot.Read.reader

    val __bin_read_t__ : 'a Bin_prot.Read.reader -> (int -> 'a t) Bin_prot.Read.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.Write.writer -> 'a t Bin_prot.Write.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.
This type offers a serialization function `sexp_of_t` that won't force its argument. Instead, it will serialize the `'a` if it is available, or just use a custom string indicating is not forced. Note that this is not a round-trippable type, thus the type does not expose `of_sexp`. To be used in debug code for example, or while tracking an Heisenbug, etc.