Commits

Anonymous committed 118e4ed

Change [null] to a monad, and add [connect] and [connectpair] primitives.

Comments (0)

Files changed (2)

iom/iom_gadget.ml

 let wirepair = Cf_gadget.wirepair
 let null = Cf_gadget.null
 
+let connect = Cf_gadget.connect
 let simplex = Cf_gadget.simplex
+let connectpair = Cf_gadget.connectpair
 let duplex = Cf_gadget.duplex
 
 let wrap = Cf_gadget.wrap

iom/iom_gadget.mli

 (** Use [wirepair] to return a pair of new wires from the scheduler. *)
 val wirepair: ('a wire * 'b wire) t
 
-(** The null wire.  Events sent on the null wire are discarded immediately, and
-    guards on the null wire never receive any events.
+(** Use [null] to construct a wire that discards every message transmitted
+    without ever delivering it.  Such wires can be useful for default arguments
+    to some gadget functions.
 *)
-val null: 'a wire
+val null: 'a wire t
 
 (** The class type of wire connectors.  Both receivers and transmitters are
     subtypes of this class type.
         method put: 'a -> unit t
     end
 
+(** Use [connect m] to obtain the wire from [m] and use it to return a receive
+    and transmit connector pair.
+*)
+val connect: 'a wire t -> ('a rx * 'a tx) t
+
 (** Use [simplex] to obtain a new wire from the scheduler and use it to return
-    a receive and transmit connector pair.
+    a receive and transmit connector pair.  This is a convenient abbreviation
+    of [connect wire].
 *)
 val simplex: ('a rx * 'a tx) t
 
 type ('x, 'y) plug = 'x rx * 'y tx
 type ('x, 'y) jack = 'y rx * 'x tx
 
-(** Use [duplex >>= f] to get a pair of new wires from the scheduler, construct
-    a {i pair} of receive and transmit connector pairs, one for each wire, and
-    apply it to the bound function [f].
+(** Use [connectpair m] to get the pair of wires from [m] and use them to
+    construct a matching jack and plug for a new duplex communication channel.
+*)
+val connectpair: ('x wire * 'y wire) t -> (('x, 'y) jack * ('x, 'y) plug) t
+
+(** Use [duplex] to get a pair of wires from the scheduler and use them to
+    construct a matching jack and plug for a new duplex communication channel.
+    This is a convenient abbreviation of [connectpair wirepair].
 *)
 val duplex: (('x, 'y) jack * ('x, 'y) plug) t