From df475a9256347564d3adc1fafc53c4d93b4e73f7 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 19 May 2012 11:32:12 -0400 Subject: Some standard library additions from Edward Z. Yang --- lib/ur/monad.ur | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/ur/monad.ur') diff --git a/lib/ur/monad.ur b/lib/ur/monad.ur index 3d03298e..ab7742fe 100644 --- a/lib/ur/monad.ur +++ b/lib/ur/monad.ur @@ -12,6 +12,8 @@ fun mp [m] (_ : monad m) [a] [b] f m = v <- m; return (f v) +val liftM = @@mp + fun foldR [K] [m] (_ : monad m) [tf :: K -> Type] [tr :: {K} -> Type] (f : nm :: Name -> t :: K -> rest :: {K} -> [[nm] ~ rest] => @@ -122,3 +124,8 @@ fun appR3 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] [tf3 :: K f [nm] [t] r1.nm r2.nm r3.nm) (fn _ _ _ => return ()) fl + +fun liftM2 [m ::: Type -> Type] (_ : monad m) [a] [b] [c] (f : a -> b -> c) (mx : m a) (my : m b) : m c = + x <- mx; + y <- my; + return (f x y) -- cgit v1.2.3