diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-25 21:51:33 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-25 21:51:33 -0300 |
| commit | 584fbca6d920e9a9f91d451667f9380714ac2175 (patch) | |
| tree | a163b916a6f8cb550c8b38ceb01ab01558687a40 /lib/kernel/Generator.ml | |
| parent | c7b754e96714eeeb9d315ee3de402d73a27d47db (diff) | |
| download | RNT-584fbca6d920e9a9f91d451667f9380714ac2175.tar.gz RNT-584fbca6d920e9a9f91d451667f9380714ac2175.zip | |
dune fmt
Diffstat (limited to 'lib/kernel/Generator.ml')
| -rw-r--r-- | lib/kernel/Generator.ml | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/kernel/Generator.ml b/lib/kernel/Generator.ml index 204699f..272bb86 100644 --- a/lib/kernel/Generator.ml +++ b/lib/kernel/Generator.ml @@ -5,8 +5,8 @@ type step = | Finished of (unit, Concepts.Condition.condition) result let start produce = - try Finished (produce ~yield:(fun tuple -> Effect.perform (Yield tuple))) with - | effect (Yield tuple), k -> Element (tuple, k) + try Finished (produce ~yield:(fun tuple -> Effect.perform (Yield tuple))) + with effect Yield tuple, k -> Element (tuple, k) let resume k = Effect.Deep.continue k () @@ -14,9 +14,7 @@ class producer_cursor produce finally = object (self) inherit Lifecycle.null inherit Identity.of_id - method to_string = "producer-cursor" - val mutable state : [`Fresh | `Live of (unit, step) Effect.Deep.continuation | `Done] = `Fresh method protocols : Protocols.Handle.protocol list = Protocols.[Cursor.make self] @@ -48,12 +46,10 @@ class producer_cursor produce finally = | None -> Ok Protocols.Cursor.{tuples; exhausted= true} | Some tuple -> fill (taken + 1) (BatFingerTree.snoc tuples tuple) in - if limit <= 0 then - Ok Protocols.Cursor.{tuples= BatFingerTree.empty; exhausted= (state = `Done)} + if limit <= 0 then Ok Protocols.Cursor.{tuples= BatFingerTree.empty; exhausted= state = `Done} else fill 0 BatFingerTree.empty method! release = match state with `Fresh | `Live _ -> self#finish | `Done -> () end -let cursor_of ?finally produce = - new producer_cursor produce finally |> Protocols.Handle.make +let cursor_of ?finally produce = new producer_cursor produce finally |> Protocols.Handle.make |
