Haskell中的Monadic TicTacToe出错

Gem*_*nus 0 monads haskell

我开始在Haskell中实现TicTacToe:

import Control.Monad.State

data Player = X | O
data Field = Player | I deriving (Eq, Show, Read)

data GameField = G [[Field]]

type GameState = State GameField ()

initGame :: GameState
initGame = do
    put $ G [[I,I,I],[I,I,I],[I,I,I]]

action = do
    initGame

test = execState action $ G [[I,I,I],[I,I,I],[I,I,I]]
Run Code Online (Sandbox Code Playgroud)

当我执行"test"时,我收到以下错误:

No instance for (Show GameField) arising from a use of `print'
Possible fix: add an instance declaration for (Show GameField)
In a stmt of an interactive GHCi command: print it
Run Code Online (Sandbox Code Playgroud)

这个问题的原因是什么,我该如何解决?

phi*_*ler 5

其实不是太神秘的消息.如果没有Show实例,请添加一个:

data GameField = G [[Field]] deriving (Show)
Run Code Online (Sandbox Code Playgroud)