Haskell中的语法错误

Haskell中的语法错误,haskell,syntax,Haskell,Syntax,我在编译Haskell脚本时出错。请帮助: 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 ^

我在编译Haskell脚本时出错。请帮助:

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!"                = "You're a whale, congratulations!"
main=do
让我告诉你体重和身高
|体重/身高^2两个问题

  • 如注释中所述,您的防护装置至少需要缩进一个额外的空间(因此管道比
    b
    缩进得更多)

  • do
    块中,您需要的不仅仅是
    let
    。例如,您可能想要测试您的函数

解决了这些问题后:

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
main=do
让我告诉你体重和身高

|重量/高度^2我认为防护罩中的
|
需要缩进,超过
bmiTell中的
b
。向右滚动。那个多余的东西在那里干什么?