Skip to content

Instantly share code, notes, and snippets.

@Swoorup
Created December 26, 2019 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Swoorup/c2792aace791f1d8961a984e49cc2605 to your computer and use it in GitHub Desktop.
Save Swoorup/c2792aace791f1d8961a984e49cc2605 to your computer and use it in GitHub Desktop.
pollutant
module Snl.Api.V1.Types where
import Data.Aeson
import Data.Proxy
import Data.Swagger
import Data.Time
import Data.UUID as UUID
import GHC.Generics
import Servant.API
import Snl.Core.Types
data Entity record =
Entity
{ entityId :: Id record
, entityRecord :: record
}
newtype Id record =
Id UUID
deriving (Eq, Show, Generic)
deriving anyclass (ToJSON, FromJSON)
deriving newtype (FromHttpApiData)
type GameId = Id GameInfo
type LobbyId = Id Lobby
data GameState
= WaitingForPlayer
| InProgress
| Finished
deriving (Generic, ToJSON, FromJSON, Show, Eq)
data GameInfo =
GameInfo
{ gameId :: GameId
, numPlayers :: Int
, gameState :: GameState
}
deriving (Eq, Show, Generic, ToJSON, FromJSON)
data Lobby =
Lobby
{ lobbyId :: LobbyId
, lobbyCreator :: PlayerId
, players :: [PlayerId]
, game :: GameInfo
}
data NewLobby =
NewLobby
{ lobbyCreator :: PlayerId
, players :: [PlayerId]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment