aboutsummaryrefslogtreecommitdiffstats
path: root/lib/evaluators/FOL.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-09-13 14:27:37 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-09-13 14:27:37 -0300
commitca8c92915bd3a7fa19ef57b8bd5a9b3f16d05254 (patch)
tree630de49e86dfc3a87b4e5187f022b7183cbe7e4a /lib/evaluators/FOL.ml
parent9b9eab0bb54ed951c56eb6551d9ee470dc5b43aa (diff)
downloadRNT-ca8c92915bd3a7fa19ef57b8bd5a9b3f16d05254.tar.gz
RNT-ca8c92915bd3a7fa19ef57b8bd5a9b3f16d05254.zip
fol evaluator
Diffstat (limited to '')
-rw-r--r--lib/evaluators/FOL.ml40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/evaluators/FOL.ml b/lib/evaluators/FOL.ml
new file mode 100644
index 0000000..70cf9de
--- /dev/null
+++ b/lib/evaluators/FOL.ml
@@ -0,0 +1,40 @@
+module Error = struct
+ open Concepts.Condition
+
+ let unknown_relation name =
+ condition "unknown-relation" "A plan named a relation that does not exist under this snapshot"
+ ("name" |=| Concepts.Value.String name)
+
+ let cancelled () =
+ condition "evaluation-cancelled" "An evaluation was stopped before it produced its result" empty
+end
+
+type plan = Base of string
+
+module Program = Protocols.Program.Make (struct
+ type t = plan
+end)
+
+let execute context = function
+ | Base name ->
+ let open Utilities.Result in
+ match context.Protocols.Context.status () with
+ | `Cancelled | `Exhausted -> Error (Error.cancelled ())
+ | `Live ->
+ let* found = Runtime.Context.resolve context name in
+ let* handle = Option.to_result ~none:(Error.unknown_relation name) found in
+ Fun.protect
+ ~finally:(fun () -> Protocols.Handle.release handle)
+ (fun () ->
+ let* enumerable = Protocols.Enumerable.require handle in
+ Protocols.Enumerable.enumerate enumerable context)
+
+class evaluator = object (self)
+ inherit Kernel.Lifecycle.null
+ inherit Kernel.Identity.of_id
+
+ method invoke ~program context = execute context program
+ method protocols : Protocols.Handle.protocol list = [Program.make self]
+end
+
+let make () = new evaluator |> Protocols.Handle.make