两个问题
正如评论中所说,你的守卫至少需要缩进一个额外的空间(所以管道更加缩进了b
)
您需要的不仅仅是块let
内部do
.例如,您可能想要测试您的功能!
解决了这些问题:
main = do let bmiTell weight height | weight / height ^ 2 <= 18.5 = "You're underweight, you emo, you!" | weight / height ^ 2 <= 25.0 = "You're supposedly normal. Pffft, I bet you're ugly!" | weight / height ^ 2 <= 30.0 = "You're fat! Lose some weight, fatty!" | otherwise = "You're a whale, congratulations!" putStrLn $ bmiTell 6 1