aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols/Relation.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/protocols/Relation.ml')
-rw-r--r--lib/protocols/Relation.ml15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/protocols/Relation.ml b/lib/protocols/Relation.ml
index ece9b8e..c05337f 100644
--- a/lib/protocols/Relation.ml
+++ b/lib/protocols/Relation.ml
@@ -1,9 +1,15 @@
+module Error = struct
+ open Concepts.Condition
+
+ let not_a_relation () =
+ condition "not-a-relation" "A handle was expected to carry the relation protocol and did not"
+ empty
+end
+
class type implementation = object
- method heading : (Concepts.Hash.hash, Concepts.Condition.condition) result
method predicate : (Concepts.Hash.hash option, Concepts.Condition.condition) result
method local_constraints : (Concepts.Hash.hash option, Concepts.Condition.condition) result
- method tuples : (Concepts.Hash.hash, Concepts.Condition.condition) result
- method contains : Concepts.Blob.t -> (bool, Concepts.Condition.condition) result
+ method contains : Concepts.Tuple.t -> (bool, Concepts.Condition.condition) result
end
type Handle.protocol += Relation of implementation
@@ -11,8 +17,7 @@ type t = implementation
let make impl = Relation (impl :> implementation)
let from handle = Handle.into handle (function Relation impl -> Some impl | _ -> None)
-let heading i = Handle.invoke i (fun o -> o#heading)
+let require handle = from handle |> Option.to_result ~none:(Error.not_a_relation ())
let predicate i = Handle.invoke i (fun o -> o#predicate)
let local_constraints i = Handle.invoke i (fun o -> o#local_constraints)
-let tuples i = Handle.invoke i (fun o -> o#tuples)
let contains i tuple = Handle.invoke i (fun o -> o#contains tuple)