[英]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 在为Real-world Haskell代码示例(第2章)准备Frege等价物时,我找不到等效的
:type readFile
What would be the closest match? 最接近的匹配是什么?
It seems you will have to use openReader :: String -> IO BufferedReader
function along with getLines :: BufferedReader -> IO [String]
function. 看来你必须使用
openReader :: String -> IO BufferedReader
函数以及getLines :: BufferedReader -> IO [String]
函数。 Then you can just combine the list of string into a single string. 然后你可以将字符串列表组合成一个字符串。
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) (这不会很好地作为评论显示,所以我做了一个答案)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.