<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffee" text="#000000">
<tt><br>
Here is a patch for the additions to MONAD_EX that we had agreed we
were happy with. Still, let me know if there are any suggestions for
improvement. Again, I am going to go ahead and commit these so I can
more easily synchronize my multiple working copies. It should have no
affect on the correctness of any existing code.<br>
<br>
Index: public/concept/monad.sig<br>
===================================================================<br>
--- public/concept/monad.sig (revision 5429)<br>
+++ public/concept/monad.sig (working copy)<br>
@@ -38,7 +38,21 @@<br>
val >>& : 'a monad_ex * 'b monad_ex -> ('a, 'b)
Product.t monad_ex<br>
val >>* : 'a monad_ex * 'b monad_ex -> ('a * 'b) monad_ex<br>
val >>@ : ('a -> 'b) monad_ex * 'a monad_ex -> 'b
monad_ex<br>
+<br>
val seq : 'a monad_ex List.t -> 'a List.t monad_ex<br>
+ val seqWith : ('a -> 'b monad_ex) -> 'a List.t -> 'b
List.t monad_ex<br>
+<br>
+ val app : 'a monad_ex List.t -> unit monad_ex<br>
+ val appWith : ('a -> 'b monad_ex) -> 'a List.t -> unit
monad_ex<br>
+<br>
+ val ignore : 'a monad_ex -> unit monad_ex<br>
+ (** {ignore m == (m >> return ())} *)<br>
+<br>
+ val when : bool -> unit monad_ex -> unit monad_ex<br>
+ (** {when b m == if b then m else (return ())} *)<br>
+<br>
+ val unless : bool -> unit monad_ex -> unit monad_ex<br>
+ (** {unless b m == if b then (return ()) else m} *)<br>
end<br>
<br>
signature MONAD = sig<br>
Index: detail/concept/mk-monad.fun<br>
===================================================================<br>
--- detail/concept/mk-monad.fun (revision 5429)<br>
+++ detail/concept/mk-monad.fun (working copy)<br>
@@ -16,6 +16,32 @@<br>
fun aM >> bM = map #2 (aM >>* bM)<br>
fun seq [] = return []<br>
| seq (xM::xMs) = map op :: (xM >>* seq xMs)<br>
+<br>
+ local <br>
+ fun seqWithTail f xs accum =<br>
+ case xs<br>
+ of [] => return (List.rev accum)<br>
+ | x::xs' => (f x) >>= (fn x' => seqWithTail f
xs' (x'::accum))<br>
+ in<br>
+ fun seqWith f xs =<br>
+ seqWithTail f xs []<br>
+ end<br>
+<br>
+ fun app (ms : 'a monad list) : unit monad =<br>
+ case ms<br>
+ of [] => return ()<br>
+ | m::ms' => m >> (app ms')<br>
+<br>
+ fun appWith (f : 'a -> 'b monad) (xs : 'a list) : unit monad =<br>
+ case xs<br>
+ of [] => return ()<br>
+ | x::xs' => (f x) >> (appWith f xs')<br>
+<br>
+ fun ignore m = m >> return ()<br>
+<br>
+ fun when b m = if b then m else return ()<br>
+ fun unless b m = if b then return () else m<br>
+<br>
end<br>
<br>
functor MkMonadP (MonadPCore : MONADP_CORE) : MONADP = struct<br>
<br>
<br>
</tt>
<pre class="moz-signature" cols="72"><tt>--
[Geoff Washburn|<a class="moz-txt-link-abbreviated" href="mailto:geoffw@cis.upenn.edu">geoffw@cis.upenn.edu</a>|<a class="moz-txt-link-freetext" href="http://www.cis.upenn.edu/~geoffw/">http://www.cis.upenn.edu/~geoffw/</a>]</tt>
</pre>
</body>
</html>