Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String “哈斯克尔”\";在IO字符串中显示为字符串_String_Haskell_Io - Fatal编程技术网

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)