aboutsummaryrefslogblamecommitdiffstats
path: root/lib/protocols/Program.ml
blob: 5b618e6443a590d69306b6f8487b520563955b0e (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                         

   

                                    
                                                                          


                                                   
 



                                                                                       
                                                                    
   
module type PROGRAM = sig
  type t
end

module Make (P : PROGRAM) = struct
  class type implementation = object
    method invoke : P.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 = Handle.invoke i (fun o -> o#invoke program)
end