aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols/Associative.ml
blob: 16fdcc8fd2730a4da178f000a70a4484a581f4a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class type implementation = object
  method update : string -> 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 value =
  Handle.invoke i (fun o ->
      let open Utilities.Result in
      let* h = o#update key value in
      Handle.require from h )