
16 Mar
2010
16 Mar
'10
5:10 p.m.
I need to read in and then combine a variable number of files. I am trying to figure out how to get the contents of all the files into an array. let fileContentsArray = getData ["dataFile1.txt", "dataFile2.txt"] getData :: [String] -> [String] getData [] = [] getData (f:files) = do fileData <- readFile f fileData : (getData files) I figured I could use readFile to open the files. But, I need to use <- to get the data out of the IO Action and into a value. I thought I could write a function like the following, but I'm getting no-where. I suspect I'm missing something basic about IO in Haskell. Can anybody point me to a good resource.... Thanks, Tim