From e76cc6f862656a3ada9fa3d4418bd060df937885 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Sat, 31 Oct 2026 02:27:40 -0300 Subject: format and where claude on fol --- lib/kernel/Generator.ml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/kernel/Generator.ml') 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 () ) -- cgit v1.2.3