aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-09-09 21:12:57 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-09-11 01:07:39 -0300
commit3c17e2cb4d5b533ed3b2a55b673642a3c4b6bb01 (patch)
tree4a988183b512090eb84a3af07a2a58e6d4943f2b
parent5310ec01d756ca96babe946d44f9f3b093bc4dda (diff)
downloadRNT-3c17e2cb4d5b533ed3b2a55b673642a3c4b6bb01.tar.gz
RNT-3c17e2cb4d5b533ed3b2a55b673642a3c4b6bb01.zip
relation with just contains and require handle
-rw-r--r--lib/protocols/Relation.ml13
-rw-r--r--lib/protocols/Relation.mli8
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/protocols/Relation.ml b/lib/protocols/Relation.ml
index ece9b8e..54454cf 100644
--- a/lib/protocols/Relation.ml
+++ b/lib/protocols/Relation.ml
@@ -1,9 +1,16 @@
+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 +18,8 @@ type t = implementation
let make impl = Relation (impl :> implementation)
let from handle = Handle.into handle (function Relation impl -> Some impl | _ -> None)
+let require handle = from handle |> Option.to_result ~none:(Error.not_a_relation ())
let heading i = Handle.invoke i (fun o -> o#heading)
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)
diff --git a/lib/protocols/Relation.mli b/lib/protocols/Relation.mli
index 4aeb562..7e64a3b 100644
--- a/lib/protocols/Relation.mli
+++ b/lib/protocols/Relation.mli
@@ -4,12 +4,12 @@ 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
val make : #implementation -> Handle.protocol
val from : Handle.t -> t Handle.interface option
+val require : Handle.t -> (t Handle.interface, Concepts.Condition.condition) result
val heading : t Handle.interface -> (Concepts.Hash.hash, Concepts.Condition.condition) result
val predicate :
@@ -18,5 +18,5 @@ val predicate :
val local_constraints :
t Handle.interface -> (Concepts.Hash.hash option, Concepts.Condition.condition) result
-val tuples : t Handle.interface -> (Concepts.Hash.hash, Concepts.Condition.condition) result
-val contains : t Handle.interface -> Concepts.Blob.t -> (bool, Concepts.Condition.condition) result
+val contains :
+ t Handle.interface -> Concepts.Tuple.t -> (bool, Concepts.Condition.condition) result