On 8/12/05, David Roundy <[EMAIL PROTECTED]> wrote: > On Fri, Aug 12, 2005 at 09:17:32AM -0300, Andr Vargas Abs da Cruz wrote: > > readDataFromFile filename = do > > bracket (openFile filename ReadMode) hClose > > (\h -> do contents <- hGetContents h > > return (lines contents)) > > > > The question is: if i try to run this, it returns me nothing (just > > an empty list). Why does this happen ? When i remove the "return" and > > put a "print" instead, it prints everything as i expected. > > I think that this may be because hGetContents puts the file in a > semi-closed state (and reads the contents lazily). Try removing the hClose > (replacing it with (return ()). Lazy IO is nice, but gets tricky at > times.
Or better yet, use 'readFile'. -- Friendly, Lemmih _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe