Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  A Question about withFile (Bin Shi)


----------------------------------------------------------------------

Message: 1
Date: Wed, 25 Jul 2012 17:40:01 +0800
From: Bin Shi <[email protected]>
Subject: [Haskell-beginners] A Question about withFile
To: [email protected]
Message-ID:
        <cahpucook2739pdphue7dfkupuu_7yygjqftrknjg7iremhk...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hello,

I wrote a simple test program as

main = do
    withFile "a.txt" ReadMode (\h -> do
        c <- hGetContents h
        putStrLn c)

then I got my expected results: I'm a.txt

but if I changed to

main = do
      c <- withFile "a.txt" ReadMode hGetContents
      putStrLn c

I got just a empty line.

Where am I wrong?

Thanks.



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 49, Issue 27
*****************************************

Reply via email to