diff options
Diffstat (limited to 'stream.sml')
-rw-r--r-- | stream.sml | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -52,6 +52,23 @@ structure Stream :> STREAM = struct fun getSubstr startOff endOff ({ contents, ... }: t) = String.substring (contents, startOff, endOff - startOff) + fun getLine (S as { contents, off, ... }: t) = + let + fun find off = + if off = size contents then + NONE + else + if String.sub (contents, off) = #"\n" then + SOME off + else + find (off + 1) + in + case find off of + SOME off' => + (SOME $ getSubstr off off' S, updateStream S s#off off' %) + | NONE => (NONE, S) + end + fun getFname ({ fname, ... }: t) = fname fun createFromInstream fname instream = |