[Haskell-cafe] How to read a file and return a String?

2013-09-04 Thread yi lu
I want to read a text file, and store it in a *String*. But readFile will get *IO String*. I search with google and they tell me it is not necessarily to do so. Can you explain to me why is this? Furthermore, How to read a file and store it in a String? In fact, I want to read a file and split it

Re: [Haskell-cafe] How to read a file and return a String?

2013-09-04 Thread Brandon Allbery
On Wed, Sep 4, 2013 at 10:21 AM, yi lu zhiwudazhanjiang...@gmail.comwrote: I want to read a text file, and store it in a *String*. But readFile will get *IO String*. I search with google and they tell me it is not necessarily to do so. Can you explain to me why is this? Furthermore, How to

Re: [Haskell-cafe] How to read a file and return a String?

2013-09-04 Thread Tom Ellis
On Wed, Sep 04, 2013 at 10:21:37PM +0800, yi lu wrote: I want to read a text file, and store it in a *String*. But readFile will get *IO String*. I search with google and they tell me it is not necessarily to do so. Can you explain to me why is this? Furthermore, How to read a file and store

Re: [Haskell-cafe] How to read a file and return a String?

2013-09-04 Thread Richard A. O'Keefe
The original poster wants to - read a file - get the contents as a String - break the string into lines - do something with the lines - and presumably print the result Easy. Put the following lines in a file called 'rf.hs': file_name = rf.hs main = readFile file_name = \string -