Add generic derivations and To/FromJSON instances

This commit is contained in:
2022-07-25 22:49:18 +01:00
parent f5604ef429
commit b8e8413daa
99 changed files with 1406 additions and 517 deletions
+11 -2
View File
@@ -1,12 +1,18 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.Corpse where
import GHC.Generics
import Data.Aeson
import ShapePicture.Data
import Geometry.Data
import Control.Lens
data CorpseResurrection = NoResurrection
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON CorpseResurrection where
toEncoding = genericToEncoding defaultOptions
instance FromJSON CorpseResurrection
data Corpse = Corpse
{ _cpID :: Int
, _cpPos :: Point2
@@ -14,5 +20,8 @@ data Corpse = Corpse
, _cpSPic :: SPic
, _cpRes :: CorpseResurrection
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Corpse where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Corpse
makeLenses ''Corpse