aboutsummaryrefslogtreecommitdiffstats
path: root/lib/evaluators
diff options
context:
space:
mode:
Diffstat (limited to 'lib/evaluators')
-rw-r--r--lib/evaluators/FOL.ml20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/evaluators/FOL.ml b/lib/evaluators/FOL.ml
index e436eeb..1c52265 100644
--- a/lib/evaluators/FOL.ml
+++ b/lib/evaluators/FOL.ml
@@ -198,10 +198,22 @@ class evaluator =
inherit Kernel.Identity.of_id
method to_string = "fol-evaluator"
- method invoke program =
- Protocols.Handle.into program (function Plan plan -> Some plan | _ -> None)
- |> Option.to_result ~none:(Error.not_a_plan (Protocols.Handle.to_string program))
- |> Utilities.Result.fmap (fun plan -> Protocols.Handle.invoke plan execute)
+ (* A plan comes resolved; stored source names its relations by path,
+ read against [within]. *)
+ method invoke program ~within =
+ let open Utilities.Result in
+ match
+ ( Protocols.Handle.into program (function Plan plan -> Some plan | _ -> None),
+ stored program )
+ with
+ | Some plan, _ -> Protocols.Handle.invoke plan execute
+ | None, Some (evaluator, _) when not (String.equal evaluator name) ->
+ Error (Error.foreign_program evaluator)
+ | None, Some (_, code) ->
+ let* term = decode code in
+ let* plan = instantiate (Kernel.Path.lookup within) term in
+ execute plan
+ | None, None -> Error (Error.not_a_plan (Protocols.Handle.to_string program))
method protocols : Protocols.Handle.protocol list = [Protocols.Evaluator.make self]
end