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





_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to