diff lib/ur/option.ur @ 1544:a99b743a3087

Basis.mkMonad
author Adam Chlipala <adam@chlipala.net>
date Fri, 19 Aug 2011 15:23:01 -0400
parents 757dbac0454d
children 36428d853c97
line wrap: on
line diff
--- a/lib/ur/option.ur	Fri Aug 19 14:20:24 2011 -0400
+++ b/lib/ur/option.ur	Fri Aug 19 15:23:01 2011 -0400
@@ -1,5 +1,11 @@
 datatype t = datatype Basis.option
 
+val monad = mkMonad {Return = @@Some,
+                     Bind = fn [a] [b] (m1 : t a) (m2 : a -> t b) =>
+                               case m1 of
+                                   None => None
+                                 | Some v => m2 v}
+
 fun eq [a] (_ : eq a) =
     mkEq (fn x y =>
              case (x, y) of