Alrick
Alrick

Reputation: 79

Haskell syntax error?

I cant compile this part of code:

game a = let 
             gameBoard ++ a
             black = test a colors
             white = (test2 a colors) - black
             createScore black white
         in 
             merge gameBoard score

geting: Syntax error in declaration (unexpected `}', possibly due to bad layout)

Thanks for help.

Upvotes: 0

Views: 111

Answers (1)

AndrewC
AndrewC

Reputation: 32475

The in is part of the same let statement, so has to be on the same line or further indented, for example

game a = let 
             gameBoard ++ a
             black = test a colors
             white = (test2 a colors) - black
             createScore black white
               in 
                 merge gameBoard score

Haskell's layout rule for syntax is roughly that if it's further in it's the same line, if it's lined up it's a new line within a block, and if it's outdented it's the end of a block, which is why your in generated a close brace.

Upvotes: 1

Related Questions