Haskell — “The last statement in a 'do' construct must be an expression”

安稳与你 提交于 2019-12-03 10:32:36

Most of the time, it's because your code is mis-aligned and compiler assumes that your "do" block ended prematurely (or has extra code that dont really belong there)

Your last line isn't something like someVar <- putStrLn "hello", by any chance, is it? You'll get that error if you try to do a variable binding on the last line, because it's equivalent to putStrLn "Hello" >>= \someVar -> — it expects there to be an expression at the end.

Incorrect indentation can lead to this error. Also, is good not to use tabs, only spaces.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!