我正在尝试Haskell。
我编写了代码并将其保存为:boolean.hs
代码是:
let area r = pi * r ^ 2
main = print(area 5 < 50)
当我这样做时,ghc -o boolean boolean.hs
我收到错误消息:
[1 of 1] Compiling Main ( boolean.hs, boolean.o )
boolean.hs:2:1:
parse error (possibly incorrect indentation or mismatched brackets)
如果有人帮助我了解如何解决这个错误,那将会很棒。
我浏览了Haskell|Wikibooks|Identation,并将代码更改为:
let
area r = pi * r ^ 2
main =
print(area 5 < 50)
仍然有:
[1 of 1] Compiling Main ( boolean.hs, boolean.o )
boolean.hs:3:1:
parse error (possibly incorrect indentation or mismatched brackets)
的问候。 :)
答案 0 :(得分:3)
您无需使用let
。只需定义函数并在main
即
area r = pi * r ^ 2
main = print (area 5 < 50)