haskell - Parse error in valid code -
haskell - Parse error in valid code -
this question has reply here:
why shouldn't mix tabs , spaces? 1 replycan see error? can't! ghc points at:
err == err = true but line ok (maybe).
data stone = black | white | none | err instance eq stone black == black = true white == white = true none == none = true err == err = true _ == _ = false instance show stone show black = "b " show white = "w " show err = "e " show none = "n " error message: main.hs:9:20: parse error on input `='
it's classic tabs versus spaces issue. replace tabs spaces:
data stone = black | white | none | err instance eq stone black == black = true white == white = true none == none = true err == err = true _ == _ = false instance show stone show black = "b " show white = "w " show err = "e " show none = "n " compiles fine.
the compiler , editor see tabs differently, utilize spaces exclusively avoid problem.
good editors can set utilize spaces indent same amount tab would, autoindent subsequent lines match, , utilize backspace if backtab.
haskell
Comments
Post a Comment