diff options
Diffstat (limited to '')
| -rw-r--r-- | lib/protocols/Associative.ml | 16 | ||||
| -rw-r--r-- | lib/protocols/Associative.mli | 11 |
2 files changed, 27 insertions, 0 deletions
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) diff --git a/lib/protocols/Associative.mli b/lib/protocols/Associative.mli new file mode 100644 index 0000000..6aecca3 --- /dev/null +++ b/lib/protocols/Associative.mli @@ -0,0 +1,11 @@ +type t + +class type implementation = object + method update : string -> Handle.t option -> Handle.t option -> (Handle.t, Concepts.Condition.condition) result +end + +val make : #implementation -> Handle.protocol + +val from : Handle.t -> t Handle.interface option + +val update : t Handle.interface -> string -> Handle.t option -> Handle.t option -> (t Handle.interface, Concepts.Condition.condition) result |
