
4 Sep
2013
4 Sep
'13
10:36 a.m.
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 it in a String?
You need to lift 'lines' into the IO functor, rather than trying to "remove" the String from IO (which doesn't make sense). Try fmap lines (readFile "filename") Tom