Haskell parse error on input '|'

2019-05-21 01:16发布

I'm getting the following error:

parse error on input '|'

with my code:

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?

Thanks in advance!

Best regards, Skyfe.

1条回答
等我变得足够好
2楼-- · 2019-05-21 02:06

The where clause should be after all guards:

fun a b 
  | one = ...
  | oterwise = ...
  where ....
查看更多
登录 后发表回答