Created
January 19, 2020 16:48
-
-
Save ChrisPenner/9228acf96f8090ebf2045bb152403b7d to your computer and use it in GitHub Desktop.
Deck of cards example for Optics By Example
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
module Folds.Filtering where | |
import Control.Lens | |
data Card = | |
Card { _name :: String | |
, _aura :: Aura | |
, _holo :: Bool -- Is the card holographic | |
, _moves :: [Move] | |
} deriving (Show, Eq) | |
data Move = | |
Move { _moveName :: String | |
, _movePower :: Int | |
} deriving (Show, Eq) | |
-- Each card has an aura-type | |
data Aura | |
= Wet | |
| Hot | |
| Spark | |
| Leafy | |
deriving (Show, Eq) | |
makeLenses ''Card | |
makeLenses ''Move | |
deck = [ Card "Skwortul" Wet False [Move "Squirt" 20] | |
, Card "Scorchander" Hot False [Move "Scorch" 20] | |
, Card "Seedasaur" Leafy False [Move "Allergize" 20] | |
, Card "Kapichu" Spark False [Move "Poke" 10 , Move "Zap" 30] | |
, Card "Elecdude" Spark False [Move "Asplode" 50] | |
, Card "Garydose" Wet True [Move "Gary's move" 40] | |
, Card "Moisteon" Wet False [Move "Soggy" 3] | |
, Card "Grasseon" Leafy False [Move "Leaf Cut" 30] | |
, Card "Spicyeon" Hot False [Move "Capsaicisize" 40] | |
, Card "Sparkeon" Spark True [Move "Shock" 40 , Move "Battery" 50] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment