Use Text and UUID instead of String
This commit is contained in:
parent
c69ef215b5
commit
9bd190b609
3 changed files with 37 additions and 15 deletions
|
@ -22,6 +22,8 @@ dependencies:
|
|||
- base >= 4.7 && < 5
|
||||
- aeson
|
||||
- servant-server
|
||||
- text
|
||||
- uuid
|
||||
- wai
|
||||
- wai-logger
|
||||
- warp
|
||||
|
|
44
src/Lib.hs
44
src/Lib.hs
|
@ -1,4 +1,5 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
|
@ -10,30 +11,43 @@ where
|
|||
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
import Data.Maybe
|
||||
import Data.Text
|
||||
import Data.UUID
|
||||
import Network.Wai
|
||||
import Network.Wai.Handler.Warp
|
||||
import Network.Wai.Logger
|
||||
import Servant
|
||||
( Get,
|
||||
JSON,
|
||||
Proxy (..),
|
||||
Raw,
|
||||
Server,
|
||||
serve,
|
||||
serveDirectoryFileServer,
|
||||
type (:<|>) (..),
|
||||
type (:>),
|
||||
)
|
||||
|
||||
data Prices = Prices
|
||||
{ usd :: Maybe String,
|
||||
usd_foil :: Maybe String,
|
||||
eur :: Maybe String,
|
||||
eur_foil :: Maybe String,
|
||||
tix :: Maybe String
|
||||
{ usd :: Maybe Text,
|
||||
usd_foil :: Maybe Text,
|
||||
eur :: Maybe Text,
|
||||
eur_foil :: Maybe Text,
|
||||
tix :: Maybe Text
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
$(deriveJSON defaultOptions ''Prices)
|
||||
|
||||
data Card = Card
|
||||
{ scryfall_id :: String,
|
||||
name :: String,
|
||||
set_code :: String,
|
||||
collector_number :: String,
|
||||
rarity :: String,
|
||||
color_identity :: String,
|
||||
oracle_text :: Maybe String,
|
||||
{ scryfall_id :: UUID,
|
||||
name :: Text,
|
||||
set_code :: Text,
|
||||
collector_number :: Text,
|
||||
rarity :: Text,
|
||||
color_identity :: Text,
|
||||
oracle_text :: Maybe Text,
|
||||
prices :: Prices
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
@ -62,7 +76,7 @@ server =
|
|||
cards :: [Card]
|
||||
cards =
|
||||
[ Card
|
||||
{ scryfall_id = "f6cd7465-9dd0-473c-ac5e-dd9e2f22f5f6",
|
||||
{ scryfall_id = fromJust $ fromText "f6cd7465-9dd0-473c-ac5e-dd9e2f22f5f6",
|
||||
name = "Esika, God of the Tree // The Prismatic Bridge",
|
||||
set_code = "KHM",
|
||||
collector_number = "168",
|
||||
|
@ -79,7 +93,7 @@ cards =
|
|||
}
|
||||
},
|
||||
Card
|
||||
{ scryfall_id = "d761ff73-0717-4ee4-996b-f5547bcf9b2f",
|
||||
{ scryfall_id = fromJust $ fromText "d761ff73-0717-4ee4-996b-f5547bcf9b2f",
|
||||
name = "Go-Shintai of Life's Origin",
|
||||
set_code = "NEC",
|
||||
collector_number = "66",
|
||||
|
@ -96,7 +110,7 @@ cards =
|
|||
}
|
||||
},
|
||||
Card
|
||||
{ scryfall_id = "e2539ff7-2b7d-47e3-bd77-3138a6c42d2b",
|
||||
{ scryfall_id = fromJust $ fromText "e2539ff7-2b7d-47e3-bd77-3138a6c42d2b",
|
||||
name = "Godsire",
|
||||
set_code = "ALA",
|
||||
collector_number = "170",
|
||||
|
|
|
@ -32,6 +32,8 @@ library
|
|||
aeson
|
||||
, base >=4.7 && <5
|
||||
, servant-server
|
||||
, text
|
||||
, uuid
|
||||
, wai
|
||||
, wai-logger
|
||||
, warp
|
||||
|
@ -48,7 +50,9 @@ executable tutor-exe
|
|||
aeson
|
||||
, base
|
||||
, servant-server
|
||||
, text
|
||||
, tutor
|
||||
, uuid
|
||||
, wai
|
||||
, wai-logger
|
||||
, warp
|
||||
|
@ -69,7 +73,9 @@ test-suite tutor-test
|
|||
, hspec-wai
|
||||
, hspec-wai-json
|
||||
, servant-server
|
||||
, text
|
||||
, tutor
|
||||
, uuid
|
||||
, wai
|
||||
, wai-logger
|
||||
, warp
|
||||
|
|
Loading…
Reference in a new issue