blob: 7cf1ea39eba42400865db5374b206fda39aa10a6 (
plain) (
tree)
|
|
module Error = struct
open Concepts.Condition
let not_indexed () =
condition "not-indexed" "A handle was expected to carry the indexed protocol and did not" empty
end
class type implementation = object
method indexes : string list
method lookup : string -> Concepts.Value.value -> (Handle.t, Concepts.Condition.condition) result
end
type Handle.protocol += Indexed of implementation
type t = implementation
let make impl = Indexed (impl :> implementation)
let from handle = Handle.into handle (function Indexed impl -> Some impl | _ -> None)
let require handle = from handle |> Option.to_result ~none:(Error.not_indexed ())
let indexes i = Handle.invoke i (fun o -> o#indexes)
let lookup i attribute value = Handle.invoke i (fun o -> o#lookup attribute value)
|