[MLton-commit] r4972

Stephen Weeks sweeks at mlton.org
Tue Dec 12 17:56:28 PST 2006


Avoided spurious "* unit" for Seq.unfold.


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

U   mltonlib/trunk/com/sweeks/basic/unstable/EXPORT
U   mltonlib/trunk/com/sweeks/basic/unstable/enumerable.fun
U   mltonlib/trunk/com/sweeks/basic/unstable/export.sml
U   mltonlib/trunk/com/sweeks/basic/unstable/in.sml
U   mltonlib/trunk/com/sweeks/basic/unstable/int.fun
U   mltonlib/trunk/com/sweeks/basic/unstable/list.0.sml
U   mltonlib/trunk/com/sweeks/basic/unstable/list.1.sml
U   mltonlib/trunk/com/sweeks/basic/unstable/ram-sequence.fun
U   mltonlib/trunk/com/sweeks/basic/unstable/seq.1.sml
U   mltonlib/trunk/com/sweeks/basic/unstable/seq.2.sml
U   mltonlib/trunk/com/sweeks/basic/unstable/sequence.sig
U   mltonlib/trunk/com/sweeks/basic/unstable/string.0.sml

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

Modified: mltonlib/trunk/com/sweeks/basic/unstable/EXPORT
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/EXPORT	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/EXPORT	2006-12-13 01:56:27 UTC (rev 4972)
@@ -26,8 +26,8 @@
 structure Array: ARRAY
 		 where type 'a elem = 'a
 		 where type 'a t = 'a ArraySlice.base
-		 where type 'a unfold = 'a
-		 where type 'a unfoldR = 'a
+		 where type ('a, 'b) unfold = 'a * 'b
+		 where type ('a, 'b) unfoldR = 'a * 'b
 structure ArraySlice: ARRAY_SLICE
 		      where type 'a base = 'a ArraySlice.base
 		      where type 'a elem = 'a
@@ -78,8 +78,8 @@
 structure Lazy: LAZY
 structure List: LIST
 		where type 'a elem = 'a
-		where type 'a unfold = 'a
-		where type 'a unfoldR = 'a
+		where type ('a, 'b) unfold = 'a * 'b
+		where type ('a, 'b) unfoldR = 'a * 'b
 structure Net: NET
 	       where type Family.inet = Net.Family.inet
 	       where type 'a Family.t = 'a Net.Family.t
@@ -207,12 +207,12 @@
 structure Seq: SEQ
 	       where type 'a elem = 'a
 	       where type 'a t = 'a Seq.t
-	       where type 'a unfold = unit
-	       where type 'a unfoldR = 'a
+	       where type ('a, 'b) unfold = 'a
+	       where type ('a, 'b) unfoldR = 'a * 'b
 structure String: STRING
 		  where type t = string
-		  where type 'a unfold = 'a
-		  where type 'a unfoldR = 'a
+		  where type ('a, 'b) unfold = 'a * 'b
+		  where type ('a, 'b) unfoldR = 'a * 'b
 structure Substring: SUBSTRING
 		     where type 'a base = 'a Substring.base
 		     where type t = Char.t VectorSlice.t
@@ -228,8 +228,8 @@
 structure Vector: VECTOR
 		  where type 'a elem = 'a
 		  where type 'a t = 'a VectorSlice.base
-		  where type 'a unfold = 'a
-		  where type 'a unfoldR = 'a
+		  where type ('a, 'b) unfold = 'a * 'b
+		  where type ('a, 'b) unfoldR = 'a * 'b
 structure VectorSlice: VECTOR_SLICE
 		       where type 'a base = 'a VectorSlice.base
 		       where type 'a elem = 'a
@@ -249,8 +249,8 @@
       type 'a elem = 'a ?.elem
       type 'a t = 'a ?.t
       type 'a t0 = 'a ?.t
-      type 'a unfold = 'a ?.unfold
-      type 'a unfoldR = 'a ?.unfoldR
+      type ('a, 'b) unfold = ('a, 'b) ?.unfold
+      type ('a, 'b) unfoldR = ('a, 'b) ?.unfoldR
       val all: ('a ?.t * ('a ?.elem -> Bool.t)) -> Bool.t
       val append: ('a ?.t * 'a ?.t) -> 'a ?.t
       val concat: 'a ?.t Seq.t -> 'a ?.t
@@ -294,13 +294,13 @@
       val toSeqR: 'a ?.t -> 'a ?.elem Seq.t
       val tokens: ('a ?.t * ('a ?.elem -> Bool.t)) -> 'a ?.t Seq.t
       val unfold: ('a * ('a -> ('b ?.elem * 'a) Option.t))
-		  -> ('b ?.t * 'a ?.unfold)
+		  -> ('b ?.t, 'a) ?.unfold
       val unfoldN: (Int.t * 'a * ((Int.t * 'a) -> ('b ?.elem * 'a) Option.t))
-		   -> ('b ?.t * 'a ?.unfold)
+		   -> ('b ?.t, 'a) ?.unfold
       val unfoldNR: (Int.t * 'a * ((Int.t * 'a) -> ('b ?.elem * 'a) Option.t))
-		    -> ('b ?.t * 'a ?.unfoldR)
+		    -> ('b ?.t, 'a) ?.unfoldR
       val unfoldR: ('a * ('a -> ('b ?.elem * 'a) Option.t))
-		   -> ('b ?.t * 'a ?.unfoldR)
+		   -> ('b ?.t, 'a) ?.unfoldR
       val update: ('a ?.t * Int.t * 'a) -> unit
       val updates: ('a ?.t * Int.t * 'a Seq.t) -> unit
       structure Unsafe:
@@ -594,8 +594,8 @@
       type 'a elem = 'a ?.elem
       datatype 'a t = nil | :: of 'a * 'a List.t
       eqtype 'a t0 = 'a List.t
-      type 'a unfold = 'a ?.unfold
-      type 'a unfoldR = 'a ?.unfoldR
+      type ('a, 'b) unfold = ('a, 'b) ?.unfold
+      type ('a, 'b) unfoldR = ('a, 'b) ?.unfoldR
       val all: ('a List.t * ('a ?.elem -> Bool.t)) -> Bool.t
       val append: ('a List.t * 'a List.t) -> 'a List.t
       val concat: 'a List.t Seq.t -> 'a List.t
@@ -639,13 +639,13 @@
       val toSeqR: 'a List.t -> 'a ?.elem Seq.t
       val tokens: ('a List.t * ('a ?.elem -> Bool.t)) -> 'a List.t Seq.t
       val unfold: ('a * ('a -> ('b ?.elem * 'a) Option.t))
-		  -> ('b List.t * 'a ?.unfold)
+		  -> ('b List.t, 'a) ?.unfold
       val unfoldN: (Int.t * 'a * ((Int.t * 'a) -> ('b ?.elem * 'a) Option.t))
-		   -> ('b List.t * 'a ?.unfold)
+		   -> ('b List.t, 'a) ?.unfold
       val unfoldNR: (Int.t * 'a * ((Int.t * 'a) -> ('b ?.elem * 'a) Option.t))
-		    -> ('b List.t * 'a ?.unfoldR)
+		    -> ('b List.t, 'a) ?.unfoldR
       val unfoldR: ('a * ('a -> ('b ?.elem * 'a) Option.t))
-		   -> ('b List.t * 'a ?.unfoldR)
+		   -> ('b List.t, 'a) ?.unfoldR
    end
 signature NET = 
    sig
@@ -1972,8 +1972,8 @@
       type 'a elem = 'a ?.elem
       type 'a t = 'a ?.t
       type 'a t0 = 'a ?.t
-      type 'a unfold = 'a ?.unfold
-      type 'a unfoldR = 'a ?.unfoldR
+      type ('a, 'b) unfold = ('a, 'b) ?.unfold
+      type ('a, 'b) unfoldR = ('a, 'b) ?.unfoldR
       val all: ('a ?.t * ('a ?.elem -> Bool.t)) -> Bool.t
       val append: ('a ?.t * 'a ?.t) -> 'a ?.t
       val concat: 'a ?.t Seq.t -> 'a ?.t
@@ -2018,21 +2018,21 @@
       val toSeqR: 'a ?.t -> 'a ?.elem Seq.t
       val tokens: ('a ?.t * ('a ?.elem -> Bool.t)) -> 'a ?.t Seq.t
       val unfold: ('a * ('a -> ('b ?.elem * 'a) Option.t))
-		  -> ('b ?.t * 'a ?.unfold)
+		  -> ('b ?.t, 'a) ?.unfold
       val unfoldN: (Int.t * 'a * ((Int.t * 'a) -> ('b ?.elem * 'a) Option.t))
-		   -> ('b ?.t * 'a ?.unfold)
+		   -> ('b ?.t, 'a) ?.unfold
       val unfoldNR: (Int.t * 'a * ((Int.t * 'a) -> ('b ?.elem * 'a) Option.t))
-		    -> ('b ?.t * 'a ?.unfoldR)
+		    -> ('b ?.t, 'a) ?.unfoldR
       val unfoldR: ('a * ('a -> ('b ?.elem * 'a) Option.t))
-		   -> ('b ?.t * 'a ?.unfoldR)
+		   -> ('b ?.t, 'a) ?.unfoldR
    end
 signature STRING = 
    sig
       eqtype 'a elem = Char.t
       type t = ?.t
       type 'a t0 = ?.t
-      type 'a unfold = 'a ?.unfold
-      type 'a unfoldR = 'a ?.unfoldR
+      type ('a, 'b) unfold = ('a, 'b) ?.unfold
+      type ('a, 'b) unfoldR = ('a, 'b) ?.unfoldR
       val all: (?.t * (Char.t -> Bool.t)) -> Bool.t
       val append: (?.t * ?.t) -> ?.t
       val concat: ?.t Seq.t -> ?.t
@@ -2080,12 +2080,12 @@
       val toUpper: ?.t -> ?.t
       val toWord8Vector: ?.t -> Word8.t VectorSlice.base
       val tokens: (?.t * (Char.t -> Bool.t)) -> ?.t Seq.t
-      val unfold: ('a * ('a -> (Char.t * 'a) Option.t)) -> (?.t * 'a ?.unfold)
+      val unfold: ('a * ('a -> (Char.t * 'a) Option.t)) -> (?.t, 'a) ?.unfold
       val unfoldN: (Int.t * 'a * ((Int.t * 'a) -> (Char.t * 'a) Option.t))
-		   -> (?.t * 'a ?.unfold)
+		   -> (?.t, 'a) ?.unfold
       val unfoldNR: (Int.t * 'a * ((Int.t * 'a) -> (Char.t * 'a) Option.t))
-		    -> (?.t * 'a ?.unfoldR)
-      val unfoldR: ('a * ('a -> (Char.t * 'a) Option.t)) -> (?.t * 'a ?.unfoldR)
+		    -> (?.t, 'a) ?.unfoldR
+      val unfoldR: ('a * ('a -> (Char.t * 'a) Option.t)) -> (?.t, 'a) ?.unfoldR
       structure Unsafe:
 	 sig
 	    val sub: (?.t * Int.t) -> Char.t
@@ -2177,8 +2177,8 @@
       type 'a elem = 'a ?.elem
       type 'a t = 'a ?.t
       type 'a t0 = 'a ?.t
-      type 'a unfold = 'a ?.unfold
-      type 'a unfoldR = 'a ?.unfoldR
+      type ('a, 'b) unfold = ('a, 'b) ?.unfold
+      type ('a, 'b) unfoldR = ('a, 'b) ?.unfoldR
       val all: ('a ?.t * ('a ?.elem -> Bool.t)) -> Bool.t
       val append: ('a ?.t * 'a ?.t) -> 'a ?.t
       val concat: 'a ?.t Seq.t -> 'a ?.t
@@ -2225,13 +2225,13 @@
       val toSeqR: 'a ?.t -> 'a ?.elem Seq.t
       val tokens: ('a ?.t * ('a ?.elem -> Bool.t)) -> 'a ?.t Seq.t
       val unfold: ('a * ('a -> ('b ?.elem * 'a) Option.t))
-		  -> ('b ?.t * 'a ?.unfold)
+		  -> ('b ?.t, 'a) ?.unfold
       val unfoldN: (Int.t * 'a * ((Int.t * 'a) -> ('b ?.elem * 'a) Option.t))
-		   -> ('b ?.t * 'a ?.unfold)
+		   -> ('b ?.t, 'a) ?.unfold
       val unfoldNR: (Int.t * 'a * ((Int.t * 'a) -> ('b ?.elem * 'a) Option.t))
-		    -> ('b ?.t * 'a ?.unfoldR)
+		    -> ('b ?.t, 'a) ?.unfoldR
       val unfoldR: ('a * ('a -> ('b ?.elem * 'a) Option.t))
-		   -> ('b ?.t * 'a ?.unfoldR)
+		   -> ('b ?.t, 'a) ?.unfoldR
       structure Unsafe:
 	 sig
 	    val sub: ('a ?.t * Int.t) -> 'a ?.elem

Modified: mltonlib/trunk/com/sweeks/basic/unstable/enumerable.fun
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/enumerable.fun	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/enumerable.fun	2006-12-13 01:56:27 UTC (rev 4972)
@@ -22,7 +22,7 @@
    fun toSeq e = let
       val (c, s) = start e
    in
-      #1 (Seq.unfold (s, fn s => next (c, s)))
+      Seq.unfold (s, fn s => next (c, s))
    end
 
 end

Modified: mltonlib/trunk/com/sweeks/basic/unstable/export.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/export.sml	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/export.sml	2006-12-13 01:56:27 UTC (rev 4972)
@@ -2,8 +2,8 @@
    EXPORT
    where type 'a Array.t = 'a Array.t
    where type 'a Array.elem = 'a Array.elem
-   where type 'a Array.unfold = 'a Array.unfold
-   where type 'a Array.unfoldR = 'a Array.unfoldR
+   where type ('a, 'b) Array.unfold = ('a, 'b) Array.unfold
+   where type ('a, 'b) Array.unfoldR = ('a, 'b) Array.unfoldR
    where type 'a ArraySlice.elem = 'a ArraySlice.elem
    where type Char.t = Char.t
    where type In.t = In.t
@@ -17,8 +17,8 @@
    where type LargeReal.t = LargeReal.t
    where type LargeWord.t = LargeWord.t
    where type 'a List.elem = 'a List.elem
-   where type 'a List.unfold = 'a List.unfold
-   where type 'a List.unfoldR = 'a List.unfoldR
+   where type ('a, 'b) List.unfold = ('a, 'b) List.unfold
+   where type ('a, 'b) List.unfoldR = ('a, 'b) List.unfoldR
    where type 'a Option.t = 'a Option.t
    where type Out.t = Out.t
    where type Radix.t = Radix.t
@@ -28,18 +28,18 @@
    where type 'a Scanner.t = 'a Scanner.t
    where type 'a Seq.t = 'a Seq.t
    where type 'a Seq.elem = 'a Seq.elem
-   where type 'a Seq.unfold = 'a Seq.unfold
-   where type 'a Seq.unfoldR = 'a Seq.unfoldR
+   where type ('a, 'b) Seq.unfold = ('a, 'b) Seq.unfold
+   where type ('a, 'b) Seq.unfoldR = ('a, 'b) Seq.unfoldR
    where type String.t = String.t
-   where type 'a String.unfold = 'a String.unfold
-   where type 'a String.unfoldR = 'a String.unfoldR
+   where type ('a, 'b) String.unfold = ('a, 'b) String.unfold
+   where type ('a, 'b) String.unfoldR = ('a, 'b) String.unfoldR
    where type Substring.t = Substring.t
    where type Time.t = Time.t
    where type Unit.t = Unit.t
    where type 'a Vector.t = 'a Vector.t
    where type 'a Vector.elem = 'a Vector.elem
-   where type 'a Vector.unfold = 'a Vector.unfold
-   where type 'a Vector.unfoldR = 'a Vector.unfoldR
+   where type ('a, 'b) Vector.unfold = ('a, 'b) Vector.unfold
+   where type ('a, 'b) Vector.unfoldR = ('a, 'b) Vector.unfoldR
    where type 'a VectorSlice.t = 'a VectorSlice.t
    where type 'a VectorSlice.elem = 'a VectorSlice.elem
    where type Word.t = Word.t

Modified: mltonlib/trunk/com/sweeks/basic/unstable/in.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/in.sml	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/in.sml	2006-12-13 01:56:27 UTC (rev 4972)
@@ -13,6 +13,6 @@
    end
 
    fun lines ins =
-      #1 (Seq.unfold ((), fn () => Option.map (getLine ins, fn s => (s, ()))))
+      Seq.unfold ((), fn () => Option.map (getLine ins, fn s => (s, ())))
 
 end

Modified: mltonlib/trunk/com/sweeks/basic/unstable/int.fun
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/int.fun	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/int.fun	2006-12-13 01:56:27 UTC (rev 4972)
@@ -32,21 +32,21 @@
    val toWord = Basis.Word.fromLargeInt o Int.toLarge
 
    fun fromToBy (start, stop, by) =
-      #1 (Seq.unfold
-          (start,
-           if by > zero then
-              (fn i => if i >= stop then None else Some (i, i + by))
-           else if by < zero then
-              (fn i => let
-                 val i = i + by
-              in
-                 if i < stop then
-                    None
-                 else
-                    Some (i, i)
-              end)
-                else
-                   die "Int.fromToBy 0"))
+      Seq.unfold
+      (start,
+       if by > zero then
+          (fn i => if i >= stop then None else Some (i, i + by))
+       else if by < zero then
+          (fn i => let
+             val i = i + by
+          in
+             if i < stop then
+                None
+             else
+                Some (i, i)
+          end)
+       else
+          die "Int.fromToBy 0")
 
    fun fromTo (start, stop) = fromToBy (start, stop, one)
 

Modified: mltonlib/trunk/com/sweeks/basic/unstable/list.0.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/list.0.sml	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/list.0.sml	2006-12-13 01:56:27 UTC (rev 4972)
@@ -13,6 +13,6 @@
 
    fun reverse l = fold (l, [], op ::)
 
-   fun toSeq l = #1 (Seq.unfold (l, fn [] => None | x :: l => Some (x, l)))
+   fun toSeq l = Seq.unfold (l, fn [] => None | x :: l => Some (x, l))
       
 end

Modified: mltonlib/trunk/com/sweeks/basic/unstable/list.1.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/list.1.sml	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/list.1.sml	2006-12-13 01:56:27 UTC (rev 4972)
@@ -39,9 +39,9 @@
 
    fun single x = [x]
 
-   type 'a unfold = 'a
+   type ('a, 'b) unfold = 'a * 'b
 
-   type 'a unfoldR = 'a
+   type ('a, 'b) unfoldR = 'a * 'b
 
    fun unfoldNR (n, b, f) =
       Util.recur

Modified: mltonlib/trunk/com/sweeks/basic/unstable/ram-sequence.fun
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/ram-sequence.fun	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/ram-sequence.fun	2006-12-13 01:56:27 UTC (rev 4972)
@@ -61,9 +61,10 @@
 
    fun ofSeq s = ofSeqN (s, Seq.size s)
 
-   type 'a unfold = 'a
-   type 'a unfoldR = 'a
+   type ('a, 'b) unfold = 'a * 'b
 
+   type ('a, 'b) unfoldR = 'a * 'b
+
    local
       fun make fold (n, b, f) = let
          val a = Array.Unsafe.make n

Modified: mltonlib/trunk/com/sweeks/basic/unstable/seq.1.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/seq.1.sml	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/seq.1.sml	2006-12-13 01:56:27 UTC (rev 4972)
@@ -3,13 +3,12 @@
    open Seq
 
    fun unfold (b, f) =
-      (Util.recur
-       (b, fn (b, loop) =>
-        delay (fn () =>
-               case f b of
-                  None => empty ()
-                | Some (a, b) => cons (a, loop b))),
-       ())
+      Util.recur
+      (b, fn (b, loop) =>
+       delay (fn () =>
+              case f b of
+                 None => empty ()
+               | Some (a, b) => cons (a, loop b)))
 
    fun unfoldN (n, b, f) =
       unfold

Modified: mltonlib/trunk/com/sweeks/basic/unstable/seq.2.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/seq.2.sml	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/seq.2.sml	2006-12-13 01:56:27 UTC (rev 4972)
@@ -22,9 +22,9 @@
 
    fun single x = cons (x, empty ())
 
-   type 'a unfold = Unit.t
+   type ('a, 'b) unfold = 'a
 
-   type 'a unfoldR = 'a
+   type ('a, 'b) unfoldR = 'a * 'b
 
    fun unfoldR (b, f) =
       Util.recur ((b, empty ()),  fn ((b, ac), loop) =>
@@ -45,7 +45,7 @@
            | Some (a, b) => loop (i, b, cons (a, ac))
        end)
 
-   fun ofList l = #1 (unfold (l, fn [] => None | x :: l => Some (x, l)))
+   fun ofList l = unfold (l, fn [] => None | x :: l => Some (x, l))
 
    fun ofListR l =
       Util.recur
@@ -59,20 +59,20 @@
    val toSeqR = reverse
      
    fun tabulate (n, f) =
-      #1 (unfold (0, fn i => if i = n then None else Some (f i, i + 1)))
+      unfold (0, fn i => if i = n then None else Some (f i, i + 1))
 
    fun map (s, f) =
-      #1 (unfold (s, fn s => Option.map (get s, fn (x, s) => (f x, s))))
+      unfold (s, fn s => Option.map (get s, fn (x, s) => (f x, s)))
 
    fun drop (s, f) =
-      #1 (unfold
-          (s, fn s =>
-           Util.recur
-           (s, fn (s, loop) =>
-            case get s of
-               None => None
-             | Some (x, s) => if f x then loop s else Some (x, s))))
-
+      unfold
+      (s, fn s =>
+       Util.recur
+       (s, fn (s, loop) =>
+        case get s of
+           None => None
+         | Some (x, s) => if f x then loop s else Some (x, s)))
+      
    fun keep (s, f) = drop (s, not o f)
 
    fun append (s, s') =
@@ -100,23 +100,23 @@
    fun join (vs, sep) = concat (separate (vs, sep))
 
    fun keepPrefix (s, f) =
-      #1 (unfold (s, fn s =>
-                  case get s of
-                     None => None
-                   | Some (x, s) => if f x then Some (x, s) else None))
+      unfold (s, fn s =>
+              case get s of
+                 None => None
+               | Some (x, s) => if f x then Some (x, s) else None)
 
    fun keepPrefixN (s, n) =
       if n < 0 then
          die "takeN"
       else
-         #1 (unfold ((s, n), fn (s, n) =>
-                     if n = 0 then
-                        None
-                     else
-                        case get s of
-                           None => die "takeN"
-                         | Some (x, s) => Some (x, (s, n - 1))))
-
+         unfold ((s, n), fn (s, n) =>
+                 if n = 0 then
+                    None
+                 else
+                    case get s of
+                       None => die "takeN"
+                     | Some (x, s) => Some (x, (s, n - 1)))
+         
    fun keepSuffix (s, f) = reverse (keepPrefix (reverse s, f))
 
    fun keepSuffixN (s, n) = dropPrefixN (s, size s - n)

Modified: mltonlib/trunk/com/sweeks/basic/unstable/sequence.sig
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/sequence.sig	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/sequence.sig	2006-12-13 01:56:27 UTC (rev 4972)
@@ -2,8 +2,8 @@
    
    include SLICEABLE
 
-   type 'a unfold
-   type 'a unfoldR
+   type ('a, 'b) unfold
+   type ('a, 'b) unfoldR
    (**
     * Used for the return state of a call to unfold{,R}.
     * Lazy constructions define this as Unit.t.
@@ -75,23 +75,24 @@
     * tabulate (n, f) returns the sequence [f 0, f 1, ..., f (n-1)].
     * It may compute the elements in any order.
     *)
-   val unfold: 'b * ('b -> ('a elem * 'b) Option.t) -> 'a t0 * 'b unfold
+   val unfold: 'b * ('b -> ('a elem * 'b) Option.t) -> ('a t0, 'b) unfold
    (**
     * unfold (b0, f) = [a0, a1, ...] where f bi = Some (ai, bi+1)
     *)
    val unfoldN:
-      Int.t * 'b * (Int.t * 'b -> ('a elem * 'b) Option.t) -> 'a t0 * 'b unfold
+      Int.t * 'b * (Int.t * 'b -> ('a elem * 'b) Option.t) -> ('a t0, 'b) unfold
    (**
     * unfoldN (n, b0, f) = [a0, a1, ..., an-1]
     * where f (i, bi) = Some (ai, bi+1)
     *)
    val unfoldNR:
-      Int.t * 'b * (Int.t * 'b -> ('a elem * 'b) Option.t) -> 'a t0 * 'b unfoldR
+      Int.t * 'b * (Int.t * 'b -> ('a elem * 'b) Option.t)
+      -> ('a t0, 'b) unfoldR
    (**
     * unfoldNR (n, b0, f) = [an-1, ..., a1, a0]
     * where f (n - 1 - i, bi) = Some (ai, bi+1)
     *)
-   val unfoldR: 'b * ('b -> ('a elem * 'b) Option.t) -> 'a t0 * 'b unfoldR
+   val unfoldR: 'b * ('b -> ('a elem * 'b) Option.t) -> ('a t0, 'b) unfoldR
    (**
     * unfoldR (b0, f) = [an-1, ..., a1, a0] where f bi = Some (ai, bi+1) and
     * f bn = None.

Modified: mltonlib/trunk/com/sweeks/basic/unstable/string.0.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/string.0.sml	2006-12-13 01:50:35 UTC (rev 4971)
+++ mltonlib/trunk/com/sweeks/basic/unstable/string.0.sml	2006-12-13 01:56:27 UTC (rev 4972)
@@ -3,10 +3,10 @@
    open String
       
    fun toSeq s =
-      #1 (Seq.unfold (0, fn i =>
-                      if i = size s then
-                         None
-                      else
-                         Some (String.sub (s, i), i + 1)))
+      Seq.unfold (0, fn i =>
+                  if i = size s then
+                     None
+                  else
+                     Some (String.sub (s, i), i + 1))
 
 end




More information about the MLton-commit mailing list