[MLton-commit] r6588

Vesa Karvonen vesak at mlton.org
Thu Apr 10 05:22:25 PDT 2008


Added mapPartial.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/concept/mk-monad.fun
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/concept/monad.sig

----------------------------------------------------------------------

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/concept/mk-monad.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/concept/mk-monad.fun	2008-04-10 01:52:11 UTC (rev 6587)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/concept/mk-monad.fun	2008-04-10 12:22:24 UTC (rev 6588)
@@ -83,6 +83,8 @@
 
    fun filter p m = m >>= (fn x => if p x then return x else zero)
 
+   fun mapPartial f m = m >>= (fn NONE => zero | SOME x => return x) o f
+
    fun sumWith x2yM =
     fn []    => zero
      | [x]   => x2yM x

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/concept/monad.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/concept/monad.sig	2008-04-10 01:52:11 UTC (rev 6587)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/concept/monad.sig	2008-04-10 12:22:24 UTC (rev 6588)
@@ -108,6 +108,7 @@
    type 'a monadp_ex
    val guard : Bool.t -> Unit.t monadp_ex
    val filter : 'a UnPr.t -> 'a monadp_ex UnOp.t
+   val mapPartial : ('a -> 'b Option.t) -> 'a monadp_ex -> 'b monadp_ex
    val sum : 'a monadp_ex List.t -> 'a monadp_ex
    val sumWith : ('a -> 'b monadp_ex) -> 'a List.t -> 'b monadp_ex
 end




More information about the MLton-commit mailing list