Yet another weakly defined bug report
Ketil Z. Malde
ketil@ii.uib.no
13 Feb 2003 10:17:28 +0100
ketil@ii.uib.no (Ketil Z. Malde) writes:
ketil@ii.uib.no (Ketil Z. Malde) writes:
> Prelude> :r
> phase `Literate pre-processor' failed (exitcode = 1)
> I've no idea what trigged this, perhaps running out of file handles?
I forgot: GHC version 5.04.1. It seems that this is definitely
trigged by running out of file handles, so apparently, I did have an
idea.
====
The following code runs out of file handles, so I am seeking
enlightenment as to why.
> -- | add data from a file to the histogram
> addFile :: FiniteMap String Int -> String -> IO (FiniteMap String Int)
> addFile fm name = do
> x <- readFile name
> return (addHist fm x)
>
> -- | add data from all files in a directory to the histogram
> addDir :: FiniteMap String Int -> String -> IO (FiniteMap String Int)
> addDir fm dir = do
> dc <- getDirectoryContents dir
> fs <- filterM doesFileExist (map ((dir++"/")++) dc)
> foldM addFile fm fs
Running addDir on a directory with few hundred files trigs it.
Shouldn't all of each file's contents be consumed by each addFile, and
thus the handle be released?
-kzm
--
If I haven't seen further, it is by standing in the footprints of giants