aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'lib/protocols')
-rw-r--r--lib/protocols/Evaluator.ml10
-rw-r--r--lib/protocols/Evaluator.mli15
-rw-r--r--lib/protocols/Executable.ml12
-rw-r--r--lib/protocols/Executable.mli19
4 files changed, 48 insertions, 8 deletions
diff --git a/lib/protocols/Evaluator.ml b/lib/protocols/Evaluator.ml
index 9f4f5c6..6a63431 100644
--- a/lib/protocols/Evaluator.ml
+++ b/lib/protocols/Evaluator.ml
@@ -1,5 +1,10 @@
+type kind = ..
+
class type implementation = object
- method invoke : Handle.t -> within:Handle.t -> (Handle.t, Concepts.Condition.condition) result
+ method parse : string -> (kind, Concepts.Condition.condition) result
+
+ method eval :
+ kind -> Handle.t list -> within:Handle.t -> (Handle.t, Concepts.Condition.condition) result
end
type Handle.protocol += Evaluator of implementation
@@ -8,4 +13,5 @@ type t = implementation
let make impl = Evaluator (impl :> implementation)
let from handle = Handle.into handle (function Evaluator impl -> Some impl | _ -> None)
let require = Handle.require from
-let invoke i program ~within = Handle.invoke i (fun o -> o#invoke program ~within)
+let parse i source = Handle.invoke i (fun o -> o#parse source)
+let eval i kind inputs ~within = Handle.invoke i (fun o -> o#eval kind inputs ~within)
diff --git a/lib/protocols/Evaluator.mli b/lib/protocols/Evaluator.mli
index 04b3612..934c5e3 100644
--- a/lib/protocols/Evaluator.mli
+++ b/lib/protocols/Evaluator.mli
@@ -1,18 +1,21 @@
type t
+type kind = ..
-(** [within] is the directory the program's paths resolve against: the
- branch state a stored program was read through, or whatever part of
- the tree a caller hands over. *)
class type implementation = object
- method invoke : Handle.t -> within:Handle.t -> (Handle.t, Concepts.Condition.condition) result
+ method parse : string -> (kind, Concepts.Condition.condition) result
+
+ method eval :
+ kind -> Handle.t list -> within:Handle.t -> (Handle.t, 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 parse : t Handle.interface -> string -> (kind, Concepts.Condition.condition) result
-val invoke :
+val eval :
t Handle.interface ->
- Handle.t ->
+ kind ->
+ Handle.t list ->
within:Handle.t ->
(Handle.t, Concepts.Condition.condition) result
diff --git a/lib/protocols/Executable.ml b/lib/protocols/Executable.ml
new file mode 100644
index 0000000..5dea52c
--- /dev/null
+++ b/lib/protocols/Executable.ml
@@ -0,0 +1,12 @@
+class type implementation = object
+ method invoke :
+ Handle.t list -> within:Handle.t -> (Handle.t, Concepts.Condition.condition) result
+end
+
+type Handle.protocol += Executable of implementation
+type t = implementation
+
+let make impl = Executable (impl :> implementation)
+let from handle = Handle.into handle (function Executable impl -> Some impl | _ -> None)
+let require = Handle.require from
+let invoke i inputs ~within = Handle.invoke i (fun o -> o#invoke inputs ~within)
diff --git a/lib/protocols/Executable.mli b/lib/protocols/Executable.mli
new file mode 100644
index 0000000..ccb63e1
--- /dev/null
+++ b/lib/protocols/Executable.mli
@@ -0,0 +1,19 @@
+type t
+
+(** [within] is the directory the program's paths resolve against: the
+ branch state a stored program was read through, or whatever part of
+ the tree a caller hands over. *)
+class type implementation = object
+ method invoke :
+ Handle.t list -> within:Handle.t -> (Handle.t, 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 invoke :
+ t Handle.interface ->
+ Handle.t list ->
+ within:Handle.t ->
+ (Handle.t, Concepts.Condition.condition) result