
24 Jun
2011
24 Jun
'11
8:51 p.m.
On Fri, Jun 24, 2011 at 11:51 PM, Jared Hance
Lines 25-31 dispatch (fl, fn) = do handle <- openFile fl ReadMode contents <- hGetContents handle let cnt = getCounter fn res = cnt contents hClose handle return res
Cleaner is:
dispatch (fl, fn) = do contents <- withFile fl ReadMode hGetContents return $ getCounter fn contents
I had thought hGetContents was lazy IO. If so, will that even work? The handle to the file will be closed before much of the file is even read. Antoine