Commits

james woodyatt committed 7fc008b

Okay. Time to stop fussing over the Cf_dyn module, which now seems
marginally improved over Cf_flow, but it the whole concept is still
pretty confusing and the utility of this data structure remains
questionable.

Comments (0)

Files changed (3)

         llscan
         fmt_llscan
         deque
-        dyn
         heap
         pqueue
         map
         set
         sbheap
         rbtree
+        dyn
         dfa
         regx
         clex
     let enter w1 w2 = lazy (loop w1 w2) in
     enter
 
+let zip =
+    let rec loop a b =
+        match Lazy.force a, Lazy.force b with
+        | Q fx, Q fy -> Q (fun i -> loop (lazy (fx i)) (lazy (fy i)))
+        | Q f, P _ -> Q (fun x -> loop (lazy (f x)) b)
+        | P _, Q f -> Q (fun y -> loop a (lazy (f y)))
+        | P (x, a), P (y, b) -> P ((x, y), lazy (loop a b))
+        | (Z, _ | _, Z) -> Z
+    in
+    let enter a b = lazy (loop a b) in
+    enter
+
 let cyclical =
     let rec loop w0 w =
         match Lazy.force w with
     let enter z = lazy (start Cf_deque.nil z) in
     enter
 
-let copy =
-    let rec start w = lazy (loop w)
-    and loop w =
-        match Lazy.force w with
-        | Z -> Z
-        | P (hd, tl) -> P ((hd, hd), start tl)
-        | Q f -> Q (fun i -> loop (lazy (f i)))
-    in
-    start
-
-let fuse =
-    let rec start a b = lazy (loop a b)
-    and loop a b =
-        match Lazy.force a, Lazy.force b with
-        | Z, _
-        | _, Z ->
-            Z
-        | P (hd1, tl1), P (hd2, tl2) ->
-            P ((hd1, hd2), start tl1 tl2)
-        | Q f1, Q f2 ->
-            Q (fun i -> loop (lazy (f1 i)) (lazy (f2 i)))
-        | Q f, P _ ->
-            Q (fun x -> loop (lazy (f x)) b)
-        | P _, Q f ->
-            Q (fun y -> loop a (lazy (f y)))
-    in
-    start
-
 module A = struct
     open Cf_either
     
         in get
 end
 
+let parallel =
+    let ( -=- ) = connect in
+    let enter a b =
+        let a = A.strip -=- a -=- A.tag in
+        let b = B.strip -=- b -=- B.tag in
+        concurrent (Cf_seq.of_list [ a; b ])
+    in
+    enter
+
 let commute =
     let rec start w s = lazy (loop w s)
     and loop w s =
 
 module Op = struct
     let ( -=- ) = connect
+    let ( -^- ) = zip
+    let ( -%- ) = parallel
     let ( ~* ) s = concurrent (Cf_seq.of_list s)
     let ( ~& ) s = sequential (Cf_seq.of_list s)
 end
 val fold: ('r -> 'o -> 'r) -> ('r -> 'i * 'r) -> 'r -> ('i, 'o) t -> 'r
 
 val connect: ('a, 'b) t -> ('b, 'c) t -> ('a, 'c) t
+val zip: ('i, 'a) t -> ('i, 'b) t -> ('i, 'a * 'b) t
+
 val cyclical: ('i, 'o) t -> ('i, 'o) t
 
 val sequential: ('a, 'b) t Cf_seq.t -> ('a, 'b) t
 val concurrent: ('a, 'b) t Cf_seq.t -> ('a, 'b) t
 
-val copy: ('i, 'o) t -> ('i, 'o * 'o) t
-val fuse: ('i, 'a) t -> ('i, 'b) t -> ('i, 'a * 'b) t
-
 module A: sig
     val tag: ('a, ('a, 'b) Cf_either.t) t
     val strip: (('a, 'b) Cf_either.t, 'a) t
     val strip: (('a, 'b) Cf_either.t, 'b) t
 end
 
+val parallel:
+    ('ia, 'oa) t -> ('ib, 'ob) t ->
+    (('ia, 'ib) Cf_either.t, ('oa, 'ob) Cf_either.t) t
+
 val commute: ('i, 'o) t -> 'i Cf_seq.t -> 'o Cf_seq.t
 val drain: ('i, 'o) t -> 'o Cf_seq.t
 val flush: ('i, 'o) t -> ('i, 'o) t
 
 module Op: sig
     val ( -=- ): ('a, 'b) t -> ('b, 'c) t -> ('a, 'c) t
+    val ( -^- ): ('i, 'a) t -> ('i, 'b) t -> ('i, 'a * 'b) t
+    val ( -%- ):
+        ('ia, 'oa) t -> ('ib, 'ob) t ->
+        (('ia, 'ib) Cf_either.t, ('oa, 'ob) Cf_either.t) t
+    
     val ( ~& ): ('i, 'o) t list -> ('i, 'o) t
     val ( ~* ): ('i, 'o) t list -> ('i, 'o) t
 end