[MLton-commit] r6275

Vesa Karvonen vesak at mlton.org
Sun Dec 16 03:04:00 PST 2007


Added printlns.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/io/text-io.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/io/text-io.sig

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/io/text-io.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/io/text-io.sml	2007-12-15 10:32:40 UTC (rev 6274)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/io/text-io.sml	2007-12-16 11:03:59 UTC (rev 6275)
@@ -4,15 +4,20 @@
  * See the LICENSE file or http://mlton.org/License for details.
  *)
 
-structure TextIO = struct
+structure TextIO : TEXT_IO = struct
    open BasisTextIO
 
-   fun println s =
-       (output (stdOut, s) ; output1 (stdOut, #"\n") ; flushOut stdOut)
+   local
+      fun mk ln ss =
+          (app (fn s => output (stdOut, s)) ss
+         ; if ln then output1 (stdOut, #"\n") else ()
+         ; flushOut stdOut)
+   in
+      val prints = mk false
+      fun println s = mk true [s]
+      val printlns = mk true
+   end
 
-   fun prints ss =
-       (app (fn s => output (stdOut, s)) ss ; flushOut stdOut)
-
    fun readFile file =
        case openIn file
         of s => Exn.after (fn () => inputAll s, fn () => closeIn s)

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/io/text-io.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/io/text-io.sig	2007-12-15 10:32:40 UTC (rev 6274)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/io/text-io.sig	2007-12-16 11:03:59 UTC (rev 6275)
@@ -9,18 +9,13 @@
    include BASIS_TEXT_IO
 
    val println : String.t Effect.t
-   (**
-    * Prints the given string to the standard output stream with a newline
-    * and flushes the stream.
-    *
-    * This is available in the top-level environment as {println}.
-    * {println s} is equivalent to:
-    *
-    *> (output (stdOut, s) ; output1 (stdOut, #"\n") ; flushOut stdOut)
-    *)
+   (** {println s} is equivalent to {prints [s, "\n"]}. *)
 
+   val printlns : String.t List.t Effect.t
+   (** {printlns} is equivalent to {println o concat}. *)
+
    val prints : String.t List.t Effect.t
-   (** {prints = print o concat} *)
+   (** {prints} is equivalent to {print o concat}. *)
 
    val readFile : String.t -> vector
    (** Reads all data from the specified file. *)




More information about the MLton-commit mailing list