From 2e8f23c7802e9afb43a0e9846416f93a63a7e592 Mon Sep 17 00:00:00 2001 From: Estevan Castilho Date: Sat, 19 Sep 2026 01:32:02 +0000 Subject: Immutable associative collection protocol --- lib/protocols/Associative.ml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/protocols/Associative.ml (limited to 'lib/protocols/Associative.ml') diff --git a/lib/protocols/Associative.ml b/lib/protocols/Associative.ml new file mode 100644 index 0000000..aa691d0 --- /dev/null +++ b/lib/protocols/Associative.ml @@ -0,0 +1,16 @@ +class type implementation = object + method update : string -> Handle.t option -> Handle.t option -> (Handle.t, Concepts.Condition.condition) result +end + +type Handle.protocol += Associative of implementation + +type t = implementation + +let make impl = Associative (impl :> implementation) + +let from handle = Handle.into handle (function Associative impl -> Some impl | _ -> None) + +let update i key reference value = Handle.invoke i (fun o -> + let open Utilities.Result in + let* h = o#update key reference value in + Handle.require from h) -- cgit v1.2.3