What is the purpose of OCaml's Lazy.lazy_from_val?
Posted
by
Ricardo
on Stack Overflow
See other posts from Stack Overflow
or by Ricardo
Published on 2012-03-18T17:39:54Z
Indexed on
2012/03/18
17:56 UTC
Read the original article
Hit count: 242
ocaml
|lazy-evaluation
The doc of Lazy.lazy_from_val
states that this function is for special cases:
val lazy_from_val : 'a -> 'a t
lazy_from_val v returns an already-forced suspension of v This is for special purposes only and should not be confused with lazy (v).
Which cases are they talking about?
If I create a pair of suspended computation from a value like:
let l1 = lazy 123
let l2 = Lazy.lazy_from_val 123
What is the difference between these two? Because Lazy.lazy_is_val l1
and Lazy.lazy_is_val l2
both return true saying that the value is already forced!
© Stack Overflow or respective owner