0

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.

5
  • I don't see a } anywhere... Commented May 3, 2014 at 7:26
  • 5
    What it is doing gameBoard ++ a?? Commented May 3, 2014 at 7:26
  • @Himanshu gameBoard and a are lists. Commented May 3, 2014 at 7:28
  • This might help:stackoverflow.com/questions/11674892/whats-with-the-in-keyword Commented May 3, 2014 at 7:29
  • 1
    @JonathonReinhart } shows up unexpectedly (and not very newbie-friendly) in error messages because indentation blocks in Haskell are nominally syntactic sugar for explicit {;}s. It really means that an indentation block ended before it was complete. Commented May 3, 2014 at 19:09

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.