Commits

camlspotter  committed 6acfc80

liftM2

  • Participants
  • Parent commits 976d2b1

Comments (0)

Files changed (2)

File lib/monad.ml

   include M
 
   let fmap f t = bind t (fun x -> return (f x))
+  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
 
   module Open_ = struct

File lib/monad_intf.ml

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