added Aeson instances
This commit is contained in:
parent
58e9e6c16c
commit
41055a8521
1 changed files with 37 additions and 0 deletions
37
src/Data/Aeson/TickLeiste.hs
Normal file
37
src/Data/Aeson/TickLeiste.hs
Normal 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)
|
Loading…
Reference in a new issue