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,13 +1,19 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.PressPlate
where
import GHC.Generics
import Data.Aeson
import Geometry.Data
import Picture
import Control.Lens
data PressPlateEvent = PressPlateId
| PPLevelReset
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON PressPlateEvent where
toEncoding = genericToEncoding defaultOptions
instance FromJSON PressPlateEvent
data PressPlate = PressPlate
{ _ppPict :: Picture
, _ppPos :: Point2
@@ -16,5 +22,8 @@ data PressPlate = PressPlate
, _ppID :: Int
, _ppText :: String
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON PressPlate where
toEncoding = genericToEncoding defaultOptions
instance FromJSON PressPlate
makeLenses ''PressPlate