Commits

Anonymous committed a62f968

Submit cf-0.1 release.

Comments (0)

Files changed (2)

 (*---------------------------------------------------------------------------*
   IMPLEMENTATION  cf_scmonad.ml
 
-  Copyright (c) 2002, James H. Woodyatt
+  Copyright (c) 2002-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
 
 type ('s, 'x, 'a) t = ('s -> 'x, 'a) Cf_cmonad.t
     (* ('a -> 's -> 'x) -> 's -> 'x *)
-    
     (* 's -> (('s * 'a) -> 'x) -> 'x *)
 
 module Op = struct let ( >>= ) m c s = m (fun a -> c a s) end
 
 let return a f s = f a s
 let init x _ _ = x
-let cont c f x = c ((f ()) x)
+let cont c f x = c (f () x)
 let load f s = f s s
 let store s f _ = f () s
 let modify c f s = f () (c s)
 let field r f s = f (r s) s
-
-let down m s f = (fun c -> m (fun () -> c)) f s
-let lift m f s = m (fun a -> (f a) s)
-
-open Op
-
-let accumulate =
-    let rec loop stack seq =
-        match Lazy.force seq with
-        | Cf_seq.P (hd, tl) -> hd >>= fun x -> loop (x :: stack) tl
-        | Cf_seq.Z -> return (List.rev stack)
-    in
-    fun s -> loop [] s
-
-let rec sequence s =
-    match Lazy.force s with
-    | Cf_seq.P (hd, tl) -> hd >>= fun _ -> sequence tl
-    | Cf_seq.Z -> return ()
+let down m s f = m (fun () -> f) s
+let lift = Op.( >>= )
 
 (*--- End of File [ cf_scmonad.ml ] ---*)

cf/cf_scmonad.mli

 (*---------------------------------------------------------------------------*
   INTERFACE  cf_scmonad.mli
 
-  Copyright (c) 2002, James H. Woodyatt
+  Copyright (c) 2002-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
 *)
 val lift: ('x, 'a) Cf_cmonad.t -> ('s, 'x, 'a) t
 
-(** Use [accumulate seq] to produce a monad that evaluates a sequence of monads
-    [seq], gathers all their intermediate results and returns them all in a
-    list (in the same order as the sequence).
-*)
-val accumulate: ('s, 'x, 'a) t Cf_seq.t -> ('s, 'x, 'a list) t
-
-(** Use [sequence seq] to produce a monad that evaluates a sequence of monads
-    [seq] and discards all the intermediate results.
-*)
-val sequence: ('s, 'x, 'a) t Cf_seq.t -> ('s, 'x, unit) t
-
 (*--- End of File [ cf_scmonad.mli ] ---*)