问题描述
我想写这种数据类型:
data GameState = GameState {
players :: [Player],lasers :: [(Float,Float,Float)],asteroids :: [Asteroid],score :: Int,width :: Int,height :: Int,keys :: S.Set Key,lastTimeAsteroidAdded :: Int,screen :: Int,mouseclicks :: S.Set (Float,Float)
}
deriving (Show,Generic,ToJSON)
到JSON文件。因此,我需要让GameState从ToJSON派生,但是现在它说我需要为Key创建一个独立的派生实例。但是我该怎么做?
我收到的消息:
No instance for (ToJSON Key)
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,so you can specify the instance context yourself
• When deriving the instance for (ToJSON GameState)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)