[Haskell-cafe] Newbie question

André Vargas Abs da Cruz andrev at ele.puc-rio.br
Fri Aug 12 08:17:32 EDT 2005


Hi everyone,

    I think this is a totally newbie question as i am a complete novice 
to Haskell. I am trying to write down a few programs using GHC in order 
to get used with the language. I am having some problems with a piece of 
code (that is supposed to return a list of lines from a text file) which 
I transcribe below:

module Test where

import IO

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.

    Thanks in advance
    André


More information about the Haskell-Cafe mailing list