0

Can you see some error? I can't! GHC points at:

Err == Err = True

But this line is ok (maybe).

data Stone = Black | White | None | Err
instance Eq Stone where
    Black == Black = True
    White == White = True
    None == None = True
    Err == Err = True
    _ == _ = False 
instance Show Stone where
    show Black = "B "
    show White = "W "
    show Err = "E "
    show None = "N "

Error message: main.hs:9:20: parse error on input `='

dev1223
  • 1,148
  • 13
  • 28

1 Answers1

5

It's the classic tabs versus spaces issue. Replace all your tabs with spaces:

data Stone = Black | White | None | Err
instance Eq Stone where
    Black == Black = True
    White == White = True
    None == None = True
    Err == Err = True
    _ == _ = False 
instance Show Stone where
    show Black = "B "
    show White = "W "
    show Err = "E "
    show None = "N "

compiles fine.

The compiler and your editor see tabs differently, so use spaces exclusively to avoid the problem.

Good editors can be set up to use spaces to indent to the same amount that a tab would, autoindent subsequent lines to match, and use backspace as if it were a backtab.

AndrewC
  • 32,300
  • 7
  • 79
  • 115