我正在使用Visual Studio Code作为首选的文本编辑器,但是下面的Haskell代码无法编译。显然是由于缩进或括号缺失的错误导致的。由于没有括号,我想知道问题出在哪里。
safeSqrt :: Either String Doubble -> Either String | Doubble
safeSqrt sx =
case sx of
Left str -> Left str
Right x -> if x < 0
then Left "Error"
else Right $ sqrt x
GHCi会抛出以下错误信息:
Main.hs:51:1: error:
parse error (possibly incorrect indentation or mismatched brackets)
|
51 | safeSqrt sx =
| ^
有人可以帮忙吗?
谢谢
汤姆
Either String Double
,中间不要用 | 管道符。 - Willem Van Onsem