小编use*_*403的帖子

Haskell:[String]到IO()

我是Haskell的新手,我正在尝试从输入中获取值列表,并从列表中每行打印一个项目.

func :: [String] -> IO ()
Run Code Online (Sandbox Code Playgroud)

当列表大小只为1时,我无法弄清楚如何打印列表中的项目.

func [] = return ()  
func [x] = return x
Run Code Online (Sandbox Code Playgroud)

我在尝试编译文件时收到此错误消息:

Couldn't match expected type `()' with actual type `String'
    In the first argument of `return', namely `x'
    In the expression: return x
Run Code Online (Sandbox Code Playgroud)

我完全失去了,我尝试过搜索,但没有找到任何东西.谢谢!

io haskell

2
推荐指数
3
解决办法
686
查看次数

标签 统计

haskell ×1

io ×1