diff options
author | Vladimir Azarov <avm@intermediate-node.net> | 2025-05-18 12:07:58 +0200 |
---|---|---|
committer | Vladimir Azarov <avm@intermediate-node.net> | 2025-05-18 12:07:58 +0200 |
commit | 183a4420d2f2a985dd26d76e63c2cdcaafedc5ad (patch) | |
tree | 8fbb929bedf4196aab73a0b630bda38cd58d4cdf /stream.sml | |
parent | 5edd85474d6d8f3a0cc06cc0250ed3db8b26fcfa (diff) |
Conditional inclusion
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 = |