Add generic derivations and To/FromJSON instances
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user