To get started, I'm trying to implement a simple tictactoe game. And I would like to be able to represent a Piece on the board, as either the string "X" or "O". This is what I have so far.module Main wheredata Piece = X | Otype Row = [Piece]type Board = [Row]-- put an X or O in a positionmove :: Board -> Piece -> Boardmove board piece = board-- check win vertically-- check win horizontally-- check win diagonallymain :: IO ()main = putStrLn "Hello World"A) Now, I'd like to be able to load code interactively, preferably within emacs. However I don't have access to my types with ghci or ghc-mod (Interactive-Haskell). In either case, this call fails with the below error.let p = Piece X<interactive>:20:9-13: Not in scope: data constructor `Piece'B) And how do I make a custom datatype that's one of two strings (enumeration of either "X" or "O"). Cabal builds and runs the abouve code, so I know it can compile. But I'm confused as to where X or O is defined, and how I would supply it as an input.C) Finally, how do we update nested lists in Haskell. I want the move function to take a Board, Piece, and Position, and return a Board. I see some results from Hoogle. Is this where Lenses or Zippers come into play?Thanks
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners