Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/library/susp.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/library/susp.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 245 - (view) (download)
Original Path: sml/branches/SMLNJ/src/MLRISC/library/susp.sml

1 : monnier 245 signature SUSPENSION =
2 :     sig
3 :     type 'a susp
4 :     val $$ : (unit -> 'a) -> 'a susp
5 :     val !! : 'a susp -> 'a
6 :     end
7 :    
8 :     structure Suspension :> SUSPENSION =
9 :     struct
10 :     datatype 'a thunk = VALUE of 'a | CLOSURE of unit -> 'a
11 :     type 'a susp = 'a thunk ref
12 :    
13 :     fun $$ e = ref(CLOSURE e)
14 :     fun !! (ref (VALUE v)) = v
15 :     | !! (r as ref(CLOSURE e)) =
16 :     let val v = e()
17 :     in r := VALUE v; v end
18 :     end
19 :    
20 :     (*
21 :     * $Log$
22 :     *)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0