String “哈斯克尔”\";在IO字符串中显示为字符串
但我需要:String “哈斯克尔”\";在IO字符串中显示为字符串,string,haskell,io,String,Haskell,Io,但我需要: "hello\nmello" 编辑: :32:9: 无法将类型“IO字符串”与“[Char]”匹配 所需类型:字符串 实际类型:IO字符串 在'putStr'的第一个参数中,即`(imp3)' 在表达式中:putStr(imp3) putStr的类型是String->IO(),您不能将其应用于imP 3::IO String,因为putStr要求的是纯字符串而不是IO字符串。这正是GHC的错误消息所报告的 我想你不熟悉monads,所以我建议你阅读许多教程中的任何一本。同时,使用p
"hello\nmello"
编辑:
:32:9:
无法将类型“IO字符串”与“[Char]”匹配
所需类型:字符串
实际类型:IO字符串
在'putStr'的第一个参数中,即`(imp3)'
在表达式中:putStr(imp3)
putStr的类型是String->IO()
,您不能将其应用于imP 3::IO String
,因为putStr
要求的是纯字符串
而不是IO字符串
。这正是GHC的错误消息所报告的
我想你不熟悉monads,所以我建议你阅读许多教程中的任何一本。同时,使用putStr如何打印?使用“putStr”而不是“print”如果你想打印“hello mello”,你会得到正确的答案。使用:putStr“\”hello\nmello\”检查:我编辑了第一篇文章。我在使用putStr、print或putStrLn时会遇到这个错误。
"hello\nmello"
"hello
mello"
<interactive>:32:9:
Couldn't match type `IO String' with `[Char]'
Expected type: String
Actual type: IO String
In the first argument of `putStr', namely `(imP 3)'
In the expression: putStr (imP 3)