diff options
Diffstat (limited to 'lib/protocols/Program.ml')
| -rw-r--r-- | lib/protocols/Program.ml | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/protocols/Program.ml b/lib/protocols/Program.ml new file mode 100644 index 0000000..49e6e2d --- /dev/null +++ b/lib/protocols/Program.ml @@ -0,0 +1,20 @@ +module type PROGRAM = sig + type t +end + +module Make (P : PROGRAM) = struct + class type implementation = object + method invoke : + program:P.t -> + Context.t -> + (Handle.t, Concepts.Condition.condition) result + end + + type Handle.protocol += Program of implementation + + type t = implementation + + let make impl = Program (impl :> implementation) + let from handle = Handle.into handle (function Program impl -> Some impl | _ -> None) + let invoke i ~program ctx = Handle.invoke i (fun o -> o#invoke ~program ctx) +end |
