Last active
May 12, 2018 03:40
-
-
Save russmatney/172cc7e401d07990f62dffd6b233ce3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | A newtype wrapper to force UserNames to be labeled, and prevent us from | |
-- passing the wrong type of name around. | |
newtype UserName = UserName Text deriving (Show, Eq) | |
newtype PetName = PetName Text deriving (Show, Eq) | |
-- | A type alias to improve the readability of our types. | |
-- An inventory is a HashMap with a Text key and Item value. | |
type Inventory = HM.HashMap Text Item | |
-- | A User record. | |
data User | |
= User | |
{ _userName :: UserName | |
, _userScore :: Int | |
, _userPet :: Maybe Pet | |
, _userInventory :: Inventory | |
} deriving (Show, Eq) | |
data Pet | |
= Pet | |
{ _petName :: PetName } deriving (Show, Eq) | |
-- | An Item record. | |
data Item | |
= Item | |
{ _itemValue :: Int | |
, _itemWeight :: Int | |
} deriving (Show, Eq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment