[MLton-commit] r6520

Vesa Karvonen vesak at mlton.org
Sun Mar 30 14:07:42 PST 2008


Added Iter.inDir.

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

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/control/iter.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/control/iter.sig

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/control/iter.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/control/iter.sml	2008-03-30 21:32:31 UTC (rev 6519)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/control/iter.sml	2008-03-30 22:07:41 UTC (rev 6520)
@@ -5,7 +5,7 @@
  *)
 
 structure Iter :> ITER = struct
-   open Option Product UnPr Effect Fn
+   open Exn Option Product UnPr Effect Fn
 
    infix 1 <|>
    infix 0 >>= &
@@ -98,6 +98,17 @@
    val inWord8Array = flip Word8Array.app
    val inWord8Vector = flip Word8Vector.app
 
+   fun inDir d e = let
+      open OS.FileSys
+      val i = openDir d
+      fun lp () =
+          case readDir i
+           of NONE   => ()
+            | SOME f => (e f : Unit.t ; lp ())
+   in
+      after (lp, fn () => closeDir i)
+   end
+
    val for = id
    fun fold f s m = (fn s => (m (fn x => s := f (x, !s)) : Unit.t ; !s)) (ref s)
    fun reduce zero plus one = fold plus zero o map one

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/control/iter.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/control/iter.sig	2008-03-30 21:32:31 UTC (rev 6519)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/control/iter.sig	2008-03-30 22:07:41 UTC (rev 6520)
@@ -134,7 +134,7 @@
 
    val take : Int.t -> 'a t UnOp.t
    (**
-    *> take n [<x(0), x(1), ..., x(m)>] = [<x(0), x(1), ..., x(m)>], m <= n
+    *> take n [<x(0), x(1), ..., x(m)>] = [<x(0), x(1), ..., x(m)>], m < n
     *> take n [<x(0), x(1), ..., x(n-1), ...>] = [<x(0), x(1), ..., x(n-1)>]
     *)
 
@@ -259,6 +259,14 @@
    val inWord8Vector : Word8Vector.t -> Word8.t t
    val inWord8VectorSlice : Word8VectorSlice.t -> Word8.t t
 
+   val inDir : String.t -> String.t t
+   (**
+    * Iterates over the files in the specified directory.  This
+    * corresponds to iterating over the files returned by repeatedly
+    * calling {OS.FileSys.readDir} with a directory stream opened with
+    * {OS.FileSys.openDir}.
+    *)
+
    val onList : 'a List.t -> 'a List.t t
    (**
     *> onList []                      = [<>]




More information about the MLton-commit mailing list