输入'|'时的Haskell解析错误 [英] Haskell parse error on input '|'

查看:147
本文介绍了输入'|'时的Haskell解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:


输入'|'分析错误

parse error on input '|'

与我的代码:

makeMove :: Player -> Board -> Maybe Board
makeMove p b | hasWinner b == Nothing = getMove p rb ri
                                        where rb = gameTree p b
                                              ri = minimax p rb
                                              ros2int (i' :> ri') = i'
                                              rb2b (b':rbs') = b
                                              getMove p (r:rs) (i:is) = let bs  = map rb2b rs
                                                                            is  = map ros2int is
                                                                            idx = elemIndex (maximum' is) is
                                                                            res (Nothing) = Nothing
                                                                            res (Just x) = Just ((bs)!!x)
                                                                        in res idx
              | otherwise = Nothing

然而,我认为这是由标签干扰通常造成的,但我检查,我只使用空格,这样就不能成为问题。有人可以帮助我吗?

However I suppose this would be caused by tabs interference usually but I checked and I only used spaces so that couldn't be the problem. Could anyone help me out on this?

提前感谢!

最好的问候,
Skyfe

Best regards, Skyfe.

推荐答案

其中子句应该是所有的守卫: p>

The where clause should be after all guards:

fun a b 
  | one = ...
  | oterwise = ...
  where ....

这篇关于输入'|'时的Haskell解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆