diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-23 03:32:15 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-23 03:32:15 -0300 |
| commit | 882511dc8c0abded18ba6abdca64938db2652771 (patch) | |
| tree | d1ebc2896cf9bb939a89c10d626d19cd5d4f591e /lib/protocols/Cursor.ml | |
| parent | b4422c99e10a8daee452b22aea84cb1f68ae54bc (diff) | |
| download | RNT-882511dc8c0abded18ba6abdca64938db2652771.tar.gz RNT-882511dc8c0abded18ba6abdca64938db2652771.zip | |
lift retaining, membership and mode checks out of ephemeral relation
Diffstat (limited to '')
| -rw-r--r-- | lib/protocols/Cursor.ml | 7 | ||||
| -rw-r--r-- | lib/protocols/Cursor.mli | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/protocols/Cursor.ml b/lib/protocols/Cursor.ml index 36db97d..75dc77d 100644 --- a/lib/protocols/Cursor.ml +++ b/lib/protocols/Cursor.ml @@ -26,6 +26,13 @@ let rec next i = | Some (_, tuple) -> Ok (Some tuple) | None -> if batch.exhausted then Ok None else next i +let rec exists i p = + let open Utilities.Result in + let* found = next i in + match found with + | None -> Ok false + | Some tuple -> if p tuple then Ok true else exists i p + let drain i ?(limit = 256) () = let open Utilities.Result in let rec loop tuples = diff --git a/lib/protocols/Cursor.mli b/lib/protocols/Cursor.mli index 08c7628..c977fec 100644 --- a/lib/protocols/Cursor.mli +++ b/lib/protocols/Cursor.mli @@ -14,6 +14,11 @@ val fetch : t Handle.interface -> int -> (batch, Concepts.Condition.condition) r val next : t Handle.interface -> (Concepts.Tuple.t option, Concepts.Condition.condition) result +val exists : + t Handle.interface -> + (Concepts.Tuple.t -> bool) -> + (bool, Concepts.Condition.condition) result + val drain : t Handle.interface -> ?limit:int -> |
