[MLton-commit] r4971

Stephen Weeks sweeks at mlton.org
Tue Dec 12 17:50:36 PST 2006


Made scanner type abstract.

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

U   mltonlib/trunk/com/sweeks/basic/unstable/EXPORT
U   mltonlib/trunk/com/sweeks/basic/unstable/date.sig
U   mltonlib/trunk/com/sweeks/basic/unstable/export.sml
U   mltonlib/trunk/com/sweeks/basic/unstable/scanner.0.sml
U   mltonlib/trunk/com/sweeks/basic/unstable/scanner.1.sml

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

Modified: mltonlib/trunk/com/sweeks/basic/unstable/EXPORT
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/EXPORT	2006-12-11 04:56:50 UTC (rev 4970)
+++ mltonlib/trunk/com/sweeks/basic/unstable/EXPORT	2006-12-13 01:50:35 UTC (rev 4971)
@@ -408,7 +408,7 @@
       val ofTimeLocal: Time.t -> ?.t
       val ofTimeUniv: Time.t -> ?.t
       val offset: ?.t -> Time.t Option.t
-      val scanner: Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t
+      val scanner: ?.t Scanner.t
       val second: ?.t -> Int.t
       val toString: ?.t -> string
       val toTime: ?.t -> Time.t
@@ -533,7 +533,7 @@
       val ofStringRadix: (string * Radix.t) -> ?.t Option.t
       val quot: (?.t * ?.t) -> ?.t
       val rem: (?.t * ?.t) -> ?.t
-      val scanner: Radix.t -> (Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t)
+      val scanner: Radix.t -> ?.t Scanner.t
       val toString: ?.t -> string
       val toStringRadix: (?.t * Radix.t) -> string
       val toWord: ?.t -> Word.t
@@ -562,7 +562,7 @@
       val ofStringRadix: (string * Radix.t) -> ?.t Option.t
       val quot: (?.t * ?.t) -> ?.t
       val rem: (?.t * ?.t) -> ?.t
-      val scanner: Radix.t -> (Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t)
+      val scanner: Radix.t -> ?.t Scanner.t
       val toString: ?.t -> string
       val toStringRadix: (?.t * Radix.t) -> string
       val toWord: ?.t -> Word.t
@@ -679,8 +679,7 @@
 		  type t = ?.Host.Address.t
 		  val == : (?.Host.Address.t * ?.Host.Address.t) -> Bool.t
 		  val ofString: string -> ?.Host.Address.t Option.t
-		  val scanner: Char.t Seq.t
-			       -> (?.Host.Address.t * Char.t Seq.t) Option.t
+		  val scanner: ?.Host.Address.t Scanner.t
 		  val toString: ?.Host.Address.t -> string
 	       end
 	 end
@@ -1039,7 +1038,7 @@
       val rem: (?.t * ?.t) -> ?.t
       val round: ?.t -> Int.t
       val sameSign: (?.t * ?.t) -> Bool.t
-      val scanner: Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t
+      val scanner: ?.t Scanner.t
       val sign: ?.t -> Int.t
       val signBit: ?.t -> Bool.t
       val sin: ?.t -> ?.t
@@ -1080,12 +1079,10 @@
 			      digits: Int.t List.t,
 			      exp: Int.t,
 			      sign: Bool.t} Option.t
-	    val scanner: Char.t Seq.t
-			 -> ({class: ?.Class.t,
-			      digits: Int.t List.t,
-			      exp: Int.t,
-			      sign: Bool.t}
-			     * Char.t Seq.t) Option.t
+	    val scanner: {class: ?.Class.t,
+			  digits: Int.t List.t,
+			  exp: Int.t,
+			  sign: Bool.t} Scanner.t
 	    val toString: {class: ?.Class.t,
 			   digits: Int.t List.t,
 			   exp: Int.t,
@@ -1133,7 +1130,7 @@
       val ofString: string -> ?.t Option.t
       val ofStringRadix: (string * Radix.t) -> ?.t Option.t
       val orb: (?.t * ?.t) -> ?.t
-      val scanner: Radix.t -> (Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t)
+      val scanner: Radix.t -> ?.t Scanner.t
       val subArr: (Word8.t ArraySlice.base * Int.t * ?.Endian.t) -> ?.t
       val subVec: (Word8.t VectorSlice.base * Int.t * ?.Endian.t) -> ?.t
       val toLarge: ?.t -> Word64.t
@@ -1891,7 +1888,7 @@
       val rem: (?.t * ?.t) -> ?.t
       val round: ?.t -> Int.t
       val sameSign: (?.t * ?.t) -> Bool.t
-      val scanner: Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t
+      val scanner: ?.t Scanner.t
       val sign: ?.t -> Int.t
       val signBit: ?.t -> Bool.t
       val sin: ?.t -> ?.t
@@ -1928,12 +1925,10 @@
 			      digits: Int.t List.t,
 			      exp: Int.t,
 			      sign: Bool.t} Option.t
-	    val scanner: Char.t Seq.t
-			 -> ({class: ?.Class.t,
-			      digits: Int.t List.t,
-			      exp: Int.t,
-			      sign: Bool.t}
-			     * Char.t Seq.t) Option.t
+	    val scanner: {class: ?.Class.t,
+			  digits: Int.t List.t,
+			  exp: Int.t,
+			  sign: Bool.t} Scanner.t
 	    val toString: {class: ?.Class.t,
 			   digits: Int.t List.t,
 			   exp: Int.t,
@@ -2168,7 +2163,7 @@
       val ofNanoseconds: IntInf.t -> ?.t
       val ofSeconds: IntInf.t -> ?.t
       val ofString: string -> ?.t Option.t
-      val scanner: Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t
+      val scanner: ?.t Scanner.t
       val toMicroseconds: ?.t -> IntInf.t
       val toMilliseconds: ?.t -> IntInf.t
       val toNanoseconds: ?.t -> IntInf.t
@@ -2303,7 +2298,7 @@
       val ofString: string -> ?.t Option.t
       val ofStringRadix: (string * Radix.t) -> ?.t Option.t
       val orb: (?.t * ?.t) -> ?.t
-      val scanner: Radix.t -> (Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t)
+      val scanner: Radix.t -> ?.t Scanner.t
       val toLarge: ?.t -> Word64.t
       val toLargeX: ?.t -> Word64.t
       val toString: ?.t -> string
@@ -2333,7 +2328,7 @@
       val ofString: string -> ?.t Option.t
       val ofStringRadix: (string * Radix.t) -> ?.t Option.t
       val orb: (?.t * ?.t) -> ?.t
-      val scanner: Radix.t -> (Char.t Seq.t -> (?.t * Char.t Seq.t) Option.t)
+      val scanner: Radix.t -> ?.t Scanner.t
       val toChar: ?.t -> Char.t
       val toLarge: ?.t -> Word64.t
       val toLargeX: ?.t -> Word64.t

Modified: mltonlib/trunk/com/sweeks/basic/unstable/date.sig
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/date.sig	2006-12-11 04:56:50 UTC (rev 4970)
+++ mltonlib/trunk/com/sweeks/basic/unstable/date.sig	2006-12-13 01:50:35 UTC (rev 4971)
@@ -53,7 +53,7 @@
     *)
    val ofTimeLocal: Time.t -> t
    val ofTimeUniv: Time.t -> t
-   val scanner: Char.t Seq.t -> (t * Char.t Seq.t) Option.t
+   val scanner: t Scanner.t
    val second: t -> Int.t
    val toString: t -> String.t
    val toTime: t -> Time.t

Modified: mltonlib/trunk/com/sweeks/basic/unstable/export.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/export.sml	2006-12-11 04:56:50 UTC (rev 4970)
+++ mltonlib/trunk/com/sweeks/basic/unstable/export.sml	2006-12-13 01:50:35 UTC (rev 4971)
@@ -25,6 +25,7 @@
    where type Real.t = Real.t
    where type Real32.t = Real32.t
    where type Real64.t = Real64.t
+   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

Modified: mltonlib/trunk/com/sweeks/basic/unstable/scanner.0.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/scanner.0.sml	2006-12-11 04:56:50 UTC (rev 4970)
+++ mltonlib/trunk/com/sweeks/basic/unstable/scanner.0.sml	2006-12-13 01:50:35 UTC (rev 4971)
@@ -1,9 +1,9 @@
 structure Scanner = struct
 
-   type 'a t = Char.t Seq.t -> ('a * Char.t Seq.t) Option.t
+   datatype 'a t = T of Char.t Seq.t -> ('a * Char.t Seq.t) Option.t
 
-   val make = id
+   val make = T
 
-   fun scan (s, cs) = s cs
+   fun scan (T s, cs) = s cs
 
 end

Modified: mltonlib/trunk/com/sweeks/basic/unstable/scanner.1.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/scanner.1.sml	2006-12-11 04:56:50 UTC (rev 4970)
+++ mltonlib/trunk/com/sweeks/basic/unstable/scanner.1.sml	2006-12-13 01:50:35 UTC (rev 4971)
@@ -2,7 +2,8 @@
 
    open Scanner
 
-   fun map (s, f) cs = Option.map (s cs, fn (x, cs) => (f x, cs))
+   fun map (s, f) =
+      make (fn cs => Option.map (scan (s, cs), fn (x, cs) => (f x, cs)))
 
    fun scanString (s, str) =
       case scan (s, String.toSeq str) of
@@ -13,7 +14,8 @@
             else
                None
 
-   fun ofBasis b s = Option.ofBasis (b (Option.toBasis o Seq.get) s)
+   fun ofBasis b =
+      make (fn s => Option.ofBasis (b (Option.toBasis o Seq.get) s))
 
 end
       




More information about the MLton-commit mailing list