haskell IO() 这里出了什么问题?

发布于 2024-11-04 04:30:05 字数 572 浏览 0 评论 0原文

嘿,我一直在做 haskell,并且在我的一张表中,我被要求做一个 buildList,

我得到了

buildList :: [String] -> IO ()
buildList thelist = do
putStr "Enter a line: "
str <- getLine
if str == ""
  then return ()
  else do let list = str:thelist
          print list
          buildList list

,我还必须添加一个 listBuilder :: IO () ,每当我尝试运行时,我都会收到一个奇怪的

ERROR file:.\week8.hs:92 - Syntax error in input (unexpected `=')

错误结论是 buildList 有问题,即使它有效,因为我不能在它下面放置任何新函数,即使是不需要使用 buildList 函数的函数,

如果有人知道如何解决这个问题,我将不胜感激。谢谢

〜汤姆

hey i have been doing haskell and with one of my sheets i was asked to do a buildList

i got

buildList :: [String] -> IO ()
buildList thelist = do
putStr "Enter a line: "
str <- getLine
if str == ""
  then return ()
  else do let list = str:thelist
          print list
          buildList list

I also had to add a listBuilder :: IO () as well which when ever i try to run I get a weird error

ERROR file:.\week8.hs:92 - Syntax error in input (unexpected `=')

it came to the conclusion that there is something wrong with the buildList, even though it works, as I cant put any new function underneath it, even ones that dont need to use the buildList function

if anyone knows how to fix this, it would be much appreciated. thanks

~tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心碎的声音 2024-11-11 04:30:05

缩进函数体,以便解析器知道它在哪里结束。

Indent the body of the function so the parser knows where it ends.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文