aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols/Registry.ml
blob: 4e3a44e8f5d5144ca39b1ea65fab4b16d34916c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class type implementation = object
  method register : string -> Handle.t -> (unit, Concepts.Condition.condition) result
  method unregister : string -> (unit, Concepts.Condition.condition) result
end

type Handle.protocol += Registry of implementation

type t = implementation

let make impl = Registry impl

let from handle = Handle.into handle (function Registry impl -> Some impl | _ -> None)

let register i key value = Handle.invoke i (fun o -> o#register key value)

let unregister i key = Handle.invoke i (fun o -> o#unregister key)