forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLazy.resi
41 lines (34 loc) · 1.4 KB
/
Lazy.resi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
type t<'a> = lazy_t<'a>
exception Undefined
/** [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.
*/
let force: t<'a> => 'a
/** [force_val x] forces the suspension [x] and returns its
result. If [x] has already been forced, [force_val x]
returns the same value again without recomputing it.
Raise {!Undefined} if the forcing of [x] tries to force [x] itself
recursively.
If the computation of [x] raises an exception, it is unspecified
whether [force_val x] raises the same exception or {!Undefined}.
*/
let force_val: t<'a> => 'a
/** [from_fun f] is the same as [lazy (f ())] but slightly more efficient.
[from_fun] should only be used if the function [f] is already defined.
In particular it is always less efficient to write
[from_fun (fun () => expr)] than [lazy expr].
*/
let from_fun: (unit => 'a) => t<'a>
/** [from_val v] returns an already-forced suspension of [v].
This is for special purposes only and should not be confused with
[lazy (v)].
*/
let from_val: 'a => t<'a>
/** [is_val x] returns [true] if [x] has already been forced and
did not raise an exception.
*/
let is_val: t<'a> => bool