1. camlspotter
  2. spotlib

Commits

camlspotter  committed a211ab1

liftM

  • Participants
  • Parent commits 976d2b1
  • Branches default

Comments (0)

Files changed (3)

File Changes.txt

View file
  • Ignore whitespace
 ------------
 
 - Added String.split
+- Added Monad.fmap2 and Monad.liftM2
 
 2.1.1
 ------------

File lib/monad.ml

View file
  • Ignore whitespace
 
   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

File lib/monad_intf.ml

View file
  • Ignore whitespace
   (** 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