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/releases/release-110.37/src/ml-yacc/lib/stream.sml
ViewVC logotype

Annotation of /sml/releases/release-110.37/src/ml-yacc/lib/stream.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 994 - (view) (download)

1 : blume 656 (* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi *)
2 : monnier 249
3 :     (* Stream: a structure implementing a lazy stream. The signature STREAM
4 :     is found in base.sig *)
5 :    
6 :     structure Stream :> STREAM =
7 :     struct
8 :     datatype 'a str = EVAL of 'a * 'a str ref | UNEVAL of (unit->'a)
9 :    
10 :     type 'a stream = 'a str ref
11 :    
12 :     fun get(ref(EVAL t)) = t
13 :     | get(s as ref(UNEVAL f)) =
14 :     let val t = (f(), ref(UNEVAL f)) in s := EVAL t; t end
15 :    
16 :     fun streamify f = ref(UNEVAL f)
17 :     fun cons(a,s) = ref(EVAL(a,s))
18 :    
19 :     end;

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