diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-10-31 02:27:40 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-10-31 02:27:40 -0300 |
| commit | e76cc6f862656a3ada9fa3d4418bd060df937885 (patch) | |
| tree | be96ff723c1d45c79b1df0fbeb1de9fbd974eea4 /lib/kernel/Generator.ml | |
| parent | 1c6c4ef41d97c0696c5c8654e08ffdfe65a18823 (diff) | |
| download | RNT-e76cc6f862656a3ada9fa3d4418bd060df937885.tar.gz RNT-e76cc6f862656a3ada9fa3d4418bd060df937885.zip | |
format and where claude on fol
Diffstat (limited to '')
| -rw-r--r-- | lib/kernel/Generator.ml | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/kernel/Generator.ml b/lib/kernel/Generator.ml index b83de3b..a037b3d 100644 --- a/lib/kernel/Generator.ml +++ b/lib/kernel/Generator.ml @@ -53,3 +53,19 @@ class producer_cursor produce finally = end let cursor_of ?finally produce = new producer_cursor produce finally |> Protocols.Handle.make + +let filter keep cursor = + cursor_of + ~finally:(fun () -> Protocols.Handle.release cursor) + (fun ~yield -> + let open Utilities.Result in + let* scan = Protocols.Cursor.require cursor in + let rec pass () = + let* next = Protocols.Cursor.next scan in + match next with + | None -> Ok () + | Some tuple -> + if keep tuple then yield tuple; + pass () + in + pass () ) |
