diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-10-31 02:27:40 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-10-31 02:27:40 -0300 |
| commit | e76cc6f862656a3ada9fa3d4418bd060df937885 (patch) | |
| tree | be96ff723c1d45c79b1df0fbeb1de9fbd974eea4 /lib/protocols/Indexed.ml | |
| parent | 1c6c4ef41d97c0696c5c8654e08ffdfe65a18823 (diff) | |
| download | RNT-e76cc6f862656a3ada9fa3d4418bd060df937885.tar.gz RNT-e76cc6f862656a3ada9fa3d4418bd060df937885.zip | |
format and where claude on fol
Diffstat (limited to 'lib/protocols/Indexed.ml')
| -rw-r--r-- | lib/protocols/Indexed.ml | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/protocols/Indexed.ml b/lib/protocols/Indexed.ml new file mode 100644 index 0000000..7cf1ea3 --- /dev/null +++ b/lib/protocols/Indexed.ml @@ -0,0 +1,20 @@ +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) |
