Commits

camlspotter  committed 4a314c0 Merge
  • Participants
  • Parent commits 85200ce, a211ab1

Comments (0)

Files changed (3)

 ------------
 
 - Added String.split
+- Added Monad.fmap2 and Monad.liftM2
 
 2.1.1
 ------------

File lib/monad.ml

   let liftM f t = bind t (fun x -> return (f x))
   let liftM2 f t1 t2 = bind t1 (fun v1 -> bind t2 (fun v2 -> return (f v1 v2)))
   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

File lib/monad_intf.ml

 
   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