added Aeson instances

This commit is contained in:
Dennis Frieberg 2020-09-21 23:13:13 +02:00
parent 58e9e6c16c
commit 41055a8521

View file

@ -0,0 +1,37 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Data.Aeson.TickLeiste
( JSONRequest (..),
JSONEvent (..),
)
where
import Data.Aeson
import Data.Aeson.TH
import qualified Data.Text as T
import Data.TickLeiste
import qualified Data.UUID as U
$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "tickType", contentsFieldName = "tickValue"}} ''Tick)
data JSONRequest
= SetPlayerTickR {sptRplayerUUID :: U.UUID, sptRtick :: Tick}
| AddPlayerTickR {aptRplayerName :: T.Text, aptRtick :: Tick}
| InitializeTickLeisteR {itlRtickLeiste :: [(Tick, [T.Text])]}
| TickLeisteR
| ChangeNameR {cnaRplayerUUID :: U.UUID, cnaRplayerName :: T.Text}
| RemovePlayerR {rmpRplayerUUID :: U.UUID}
deriving (Show,Eq)
$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "requestType"}, fieldLabelModifier = drop 4} ''JSONRequest)
data JSONEvent
= SetPlayerTickE {sptEplayerUUID :: U.UUID, sptEtick :: Tick}
| AddPlayerTickE {aptEplayerUUID :: U.UUID, aptEplayerName :: T.Text, aptEtick :: Tick}
| InitializeTickLeisteE {itlEtickLeiste :: [(Tick, [(U.UUID, T.Text)])]}
| ChangeNameE {cnaEplayerUUID :: U.UUID, cnaEplayerName :: T.Text}
| RemovePlayerE {rmpEplayerUUID :: U.UUID}
deriving (Show,Eq)
$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "eventType"}, fieldLabelModifier = drop 4} ''JSONEvent)