| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
CardParts.Cards
Description
Combined (value + suit) card data type and its processing functions
Documentation
This type represents a card - combination of suit and value.
Instances
| Eq Card Source # | |
| Ord Card Source # | |
| Show Card Source # | |
| Generic Card Source # | |
| FromJSON Card Source # | |
Defined in CardParts.Cards | |
| ToJSON Card Source # | |
Defined in CardParts.Cards Methods toEncoding :: Card -> Encoding toJSONList :: [Card] -> Value toEncodingList :: [Card] -> Encoding | |
| type Rep Card Source # | |
Defined in CardParts.Cards type Rep Card = D1 ('MetaData "Card" "CardParts.Cards" "ofc-calc-haskell-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Card" 'PrefixI 'True) (S1 ('MetaSel ('Just "value") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: S1 ('MetaSel ('Just "suit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Suit))) | |
parseCard :: String -> Either String Card Source #
This function gets a string which represents full card combination (value + suit)
and returns a Card wrapped with Right. The function uses parseValue and parseSuit functions.
Passed string should have length 2 and have format "{VALUE}{SUIT}".
Examples:
parseCard "2c" =RightTwoClubsparseCard "As" =RightAceSpadesparseCard "" =Left"Can't process emtpy string" parseCard "22c" =Left"Argument length should be 2" parseCard Zd =Left"There is no broadway card, which could be represented with 'Z'" parseCard "5f" =Left"There is no card suit marked as 'f'" parseCard "2x" =Left"There is no card suit marked as 'x'"