1. james woodyatt
  2. oni


jhwoodyatt  committed df338d0

Remove [substate] and add [createM].

  • Participants
  • Parent commits 5ea7bf1
  • Branches default

Comments (0)

Files changed (2)

File cf/cf_gadget.ml

View file
  • Ignore whitespace
     fun w ->
         start (loop w)
-class virtual ['i, 'o] substate = object
-    method virtual next: 'a. ('i, 'o, 'a) t
 class virtual ['i, 'o] next = object(self)
     method private virtual guard: ('i, 'o, unit) guard
     method next: 'a. ('i, 'o, 'a) t = guard self#guard
 let create f c = duplex (fun (x, y) -> (f x)#start (fun () -> c y))
+let createM f c = duplex (fun (x, y) -> f x (fun m -> m#start (fun () -> c y)))
 (*--- End of File [ cf_gadget.ml ] ---*)

File cf/cf_gadget.mli

View file
  • Ignore whitespace
     ('x, 'i, 'o) #rx -> ('y, 'i, 'o) #tx -> ('x, 'y) Cf_flow.t ->
     ('i, 'o, unit) t
-(** Use [inherit \['i, 'o\] substate] to require the derived class to inherit
-    a public [next] method.
-class virtual ['i, 'o] substate:
-    object('self)        
-        (** Use [obj#next] to transition the state of the gadget to [obj]. *)
-        method virtual next: 'a. ('i, 'o, 'a) t
-    end
 (** Use [inherit \['i, 'o\] next] to derive a class that implements an
     intermediate state in a machine.
     (('c, 'n, 'i, 'o) plug -> ('i, 'o) #start) ->
     ('i, 'o, ('c, 'n, 'i, 'o) jack) t
+(** Use [createM f] to create a duplex channel, and apply [f] to the resulting
+    plug to obtain a continuation monad that evaluates to the initial state of
+    a machine.  The machine is started and the corresponding jack is returned.
+val createM:
+    (('c, 'n, 'i, 'o) plug -> ('i, 'o, ('i, 'o) #start) t) ->
+    ('i, 'o, ('c, 'n, 'i, 'o) jack) t
 (*--- End of File [ cf_gadget.mli ] ---*)