diff options
Diffstat (limited to '')
| -rw-r--r-- | lib/protocols/Cursor.ml | 2 | ||||
| -rw-r--r-- | lib/protocols/Cursor.mli | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/protocols/Cursor.ml b/lib/protocols/Cursor.ml index f9bd697..f53bfa1 100644 --- a/lib/protocols/Cursor.ml +++ b/lib/protocols/Cursor.ml @@ -39,3 +39,5 @@ let drain i ?(limit = 256) () = if batch.exhausted then Ok tuples else loop tuples in loop BatFingerTree.empty + +let consuming cursor f = Handle.releasing cursor (fun () -> Result.bind (require cursor) f) diff --git a/lib/protocols/Cursor.mli b/lib/protocols/Cursor.mli index ff6c027..deccf2a 100644 --- a/lib/protocols/Cursor.mli +++ b/lib/protocols/Cursor.mli @@ -19,3 +19,9 @@ val drain : ?limit:int -> unit -> (Concepts.Tuple.t BatFingerTree.t, Concepts.Condition.condition) result + +(** [f] over [cursor], which is released once [f] returns. *) +val consuming : + Handle.t -> + (t Handle.interface -> ('a, Concepts.Condition.condition) result) -> + ('a, Concepts.Condition.condition) result |
