[MLton-commit] r6467

Vesa Karvonen vesak at mlton.org
Mon Mar 10 09:11:28 PST 2008


Added Option.option for eliminating options.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/data/option.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/data/option.sig

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/data/option.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/data/option.sml	2008-03-09 20:05:42 UTC (rev 6466)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/data/option.sml	2008-03-10 17:11:27 UTC (rev 6467)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2006-2007 SSH Communications Security, Helsinki, Finland
+(* Copyright (C) 2006-2008 SSH Communications Security, Helsinki, Finland
  *
  * This code is released under the MLton license, a BSD-style license.
  * See the LICENSE file or http://mlton.org/License for details.
@@ -6,11 +6,16 @@
 
 structure Option : OPTION = struct
    open Option
-   val isNone = fn NONE   => true
-                 | SOME _ => false
-   fun collate cmp = fn (NONE, NONE)       => EQUAL
-                      | (SOME _, NONE)     => GREATER
-                      | (NONE, SOME _)     => LESS
-                      | (SOME x1, SOME x2) => cmp (x1, x2)
+   val isNone =
+    fn NONE   => true
+     | SOME _ => false
+   fun collate cmp =
+    fn (NONE,   NONE)   => EQUAL
+     | (SOME _, NONE)   => GREATER
+     | (NONE,   SOME _) => LESS
+     | (SOME a, SOME b) => cmp (a, b)
+   fun option (none, some) =
+    fn NONE => none ()
+     | SOME x => some x
    fun iso ? = Pair.map (map, map) ?
 end

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/data/option.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/data/option.sig	2008-03-09 20:05:42 UTC (rev 6466)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/data/option.sig	2008-03-10 17:11:27 UTC (rev 6467)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2006-2007 SSH Communications Security, Helsinki, Finland
+(* Copyright (C) 2006-2008 SSH Communications Security, Helsinki, Finland
  *
  * This code is released under the MLton license, a BSD-style license.
  * See the LICENSE file or http://mlton.org/License for details.
@@ -21,6 +21,14 @@
     * uses the provided comparison function.
     *)
 
+   val option : (Unit.t -> 'b) * ('a -> 'b) -> 'a t -> 'b
+   (**
+    * Eliminate an option.
+    *
+    *> option (none, some) NONE     = none ()
+    *> option (none, some) (SOME x) = some x
+    *)
+
    (** == Generic Programming == *)
 
    val iso : ('a, 'b) Iso.t -> ('a t, 'b t) Iso.t




More information about the MLton-commit mailing list