Dierk
Dierk

Reputation: 1308

What is the Frege equivalent to Haskell "readFile"?

While preparing the Frege equivalents for the Real-world Haskell code examples (chapter 2), I could not find the equivalent for

:type readFile

What would be the closest match?

Upvotes: 3

Views: 250

Answers (2)

Dierk
Dierk

Reputation: 1308

Ok, I made this

readFile :: String -> IO [String]
readFile fileName = do
    file <- openReader fileName
    file.getLines

(This wouldn't be displayed nicely as a comment, so I made it an answer)

Upvotes: 2

Ankur
Ankur

Reputation: 33657

It seems you will have to use openReader :: String -> IO BufferedReader function along with getLines :: BufferedReader -> IO [String] function. Then you can just combine the list of string into a single string.

Upvotes: 5

Related Questions