[Haskell-cafe] operating on a hundred files at once

Jefferson Heard jeff at renci.org
Mon Apr 9 13:34:12 EDT 2007

I have a series of NxM numeric tables I'm doing a quick
mean/variance/t-test etcetera on.  The cell t1 [i,j] corresponds exactly
to the cells t2..N [i,j], and so it's perfectly possible to read one
item at a time from each of the 100 files and compute the mean/variance
etcetera on all cells that way.  So what I propose to do is something
along the lines of:

openAndProcess filename = 
f <- readFile filename
return (map (L.split ',') . lines $ f)

main = do 
	fs <- getArgs
	let items = map (map read) . map openAndProcess fs 
	in do print . map (map $ mean) items
	      print . map (map $ variance) items

How close am I to doing the right thing here? As I understand it, this
will result in one hundred IO [String] instances being returned by the
call to (map openAndProcess $ filenames).  Do I need to do something
special to lift (read), (mean), and (variance), or even (map) into the
IO monad so they can process the input as needed?

Thanks in advance,
-- Jeff

More information about the Haskell-Cafe mailing list