how to read a file's content to a string?
Tue, 5 Mar 2002 18:36:01 -0600 (CST)
On Tue, 5 Mar 2002, Zhe Fu wrote:
> I want to read a file's content into a string.
> content :: FilePath -> String
> content f = readFile f
> But when there is a type error:
> Type error in explicitly typed binding
> *** Term : content
> *** Type : FilePath -> IO String
> *** Does not match : FilePath -> String
> How can I solve it?
> Haskell mailing list
Essentially, what you are trying to do is invalid. you have to write
some function that results in a IO String.
I haven't read these but they might help.
(cut and paste from haskell wiki front page)
ThatAnnoyingIoType: I have an IO String but I need a String - what do I do
UsingIo: What's that IO type anyway? How do I do I/O in Haskell?