Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell parse error on input '|'

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.

like image 540
user2999349 Avatar asked Aug 17 '26 21:08

user2999349


1 Answers

The where clause should be after all guards:

fun a b 
  | one = ...
  | oterwise = ...
  where ....
like image 117
Tomo Avatar answered Aug 20 '26 11:08

Tomo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!