[MLton-commit] r5531

Vesa Karvonen vesak at mlton.org
Wed Apr 18 01:24:11 PDT 2007


Added memo.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/lazy/promise.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/lazy/promise.sig

----------------------------------------------------------------------

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/lazy/promise.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/lazy/promise.sml	2007-04-18 08:20:45 UTC (rev 5530)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/lazy/promise.sml	2007-04-18 08:24:10 UTC (rev 5531)
@@ -10,7 +10,9 @@
    withtype 'a t = 'a status ref ref
 
    fun lazy th = ref (ref (LAZY th))
+
    fun eager x = ref (ref (EAGER (Sum.INR x)))
+
    fun delay th = lazy (ref o ref o EAGER o (fn () => Exn.eval th))
 
    fun replay s = Sum.sum (Exn.throw, Fn.id) s
@@ -28,11 +30,10 @@
            | EAGER x => replay x
        end
 
-   fun toThunk promise =
-       case !(!promise) of
-          EAGER s => Sum.sum (Basic.raising, Fn.const) s
-        | LAZY _ => fn () => force promise
+   fun toThunk promise = fn () => force promise
 
+   fun memo th = toThunk (delay th)
+
    fun tie s k =
        case !(!s) of
           EAGER _ => raise Fix.Fix

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/lazy/promise.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/lazy/promise.sig	2007-04-18 08:20:45 UTC (rev 5530)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/lazy/promise.sig	2007-04-18 08:24:10 UTC (rev 5531)
@@ -68,6 +68,9 @@
     * deliver the resulting promise.
     *)
 
+   val memo : 'a Thunk.t UnOp.t
+   (** {memo th} is equivalent to {toThunk (delay th)}. *)
+
    val toThunk : 'a t -> 'a Thunk.t
    (**
     * Converts a promise into a thunk.  This can be useful for working




More information about the MLton-commit mailing list