Commits

camlspotter committed a211ab1

liftM

Comments (0)

Files changed (3)

 ------------
 
 - Added String.split
+- Added Monad.fmap2 and Monad.liftM2
 
 2.1.1
 ------------
 
   let fmap f t = bind t (fun x -> return (f x))
   let map ~f t = fmap f t
+  let liftM = fmap
+
+  let fmap2 f t1 t2 = 
+    bind t1 (fun a1 ->
+      bind t2 (fun a2 ->
+        return (f a1 a2)))
+  let liftM2 = fmap2
 
   module Open_ = struct
     let bind = M.bind

lib/monad_intf.ml

   (** fmap in Haskell *)
   val map : f:('a -> 'b) -> 'a t -> 'b t
   (** fmap in Haskell *)
+  val liftM : ('a -> 'b) -> 'a t -> 'b t
+    
+  val fmap2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
+  val liftM2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
 
   val void : 'a t -> unit t