1. james woodyatt
  2. oni

Commits

james woodyatt  committed e73cdb8

Add a signature for the Cf_xdfa module. Remove some superfluous functions
from the new Cf_llscan module.

  • Participants
  • Parent commits 45c580e
  • Branches sideline

Comments (0)

Files changed (3)

File cf/cf_llscan.ml

View file
         | None -> altz tl s
         | Some _ as r -> r
 
-let rec filter f p s =
-    match p s with
-    | None -> None
-    | Some (x, s) as v -> if f x then v else filter f p s
-
-let map f p s =
-    match p s with
-    | None -> None
-    | Some (r, s) -> Some (f r, s)
-
-let rec optmap f p s =
-    match p s with
-    | None -> None
-    | Some (x, s) ->
-        match f x with
-        | None -> optmap f p s
-        | Some y -> Some (y, s)
-
-let rec unfold =
-    let rec loop p s =
-        match p s with
-        | None -> Cf_seq.Z
-        | Some (r, s) -> Cf_seq.P (r, lazy (loop p s))
-    in
-    let start p s = lazy (loop p s) in
-    start
-
 exception Error
 
 let err =
     | None -> err ?f () s
     | Some _ as r -> r
 
+let rec unfold =
+    let rec loop p s =
+        match p s with
+        | None -> Cf_seq.Z
+        | Some (r, s) -> Cf_seq.P (r, lazy (loop p s))
+    in
+    let start p s = lazy (loop p s) in
+    start
+
 (*--- $File$ ---*)

File cf/cf_llscan.mli

View file
 val alt: ('s, 'r) t list -> ('s, 'r) t
 val altz: ('s, 'r) t Cf_seq.t -> ('s, 'r) t
 
-val filter: ('r -> bool) -> ('s, 'r) t -> ('s, 'r) t
-val map: ('x -> 'y) -> ('s, 'x) t -> ('s, 'y) t
-val optmap: ('x -> 'y option) -> ('s, 'x) t -> ('s, 'y) t
-
-val unfold: ('s, 'r) t -> 's Cf_seq.t -> 'r Cf_seq.t
-
 exception Error
 val err: ?f:('s Cf_seq.t -> exn) -> unit -> ('s, 'r) t
 val req: ?f:('s Cf_seq.t -> exn) -> ('s, 'r) t -> ('s, 'r) t
 
+val unfold: ('s, 'r) t -> 's Cf_seq.t -> 'r Cf_seq.t
+
 (*--- $File$ ---*)

File cf/cf_xdfa.mli

View file
   OF THE POSSIBILITY OF SUCH DAMAGE. 
  *---------------------------------------------------------------------------*)
 
+module type Symbol = sig
+    type t and 'a map
+    val map: (t -> 'a) -> 'a map
+    val get: 'a map -> t -> 'a
+end
+
+module type T = sig
+    module S: Symbol
+    
+    type 'a x
+    
+    val nil: 'a x
+    
+    type 'a r
+    type 'a t = (S.t, 'a) Cf_llscan.t
+    
+    module Op: sig
+        val ( $| ): 'a x -> 'a x -> 'a x
+        val ( $& ): 'a x -> 'a x -> 'a x
+        
+        val ( !* ): 'a x -> 'a x
+        val ( !+ ): 'a x -> 'a x
+        val ( !? ): 'a x -> 'a x
+        val ( !: ): S.t -> 'a x
+        val ( !^ ): (S.t -> bool) -> 'a x
+        val ( !~ ): S.t Cf_seq.t -> 'a x
+        
+        val ( $= ): 'a x -> 'a -> 'a r
+        val ( $> ): 'a x -> (S.t Cf_seq.t -> 'a) -> 'a r
+        val ( $@ ): 'a x -> (int -> 'a t) -> 'a r
+        val ( !@ ): 'a r list -> 'a r
+    end
+    
+    val create: 'a r -> 'a t
+end
+
+module Create(S: Symbol): T with module S = S
+
 (*--- $File$ ---*)