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.Shockwave
where
import GHC.Generics
import Data.Aeson
import Color
import Geometry.Data
import Control.Lens
data ShockwaveDirection = OutwardShockwave | InwardShockwave
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ShockwaveDirection where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ShockwaveDirection
data Shockwave = Shockwave
{ _swColor :: Color
, _swDirection :: ShockwaveDirection
@@ -18,5 +24,8 @@ data Shockwave = Shockwave
, _swMaxTime :: Int
, _swTimer :: Int
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Shockwave where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Shockwave
makeLenses ''Shockwave