ofc-calc-haskell-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

CardParts.Suits

Description

Card suit data type and its processing functions

Synopsis

Documentation

data Suit Source #

This type represents card suit.

Constructors

Hearts 
Diamonds 
Clubs 
Spades 

Instances

Instances details
Bounded Suit Source # 
Instance details

Defined in CardParts.Suits

Enum Suit Source # 
Instance details

Defined in CardParts.Suits

Methods

succ :: Suit -> Suit #

pred :: Suit -> Suit #

toEnum :: Int -> Suit #

fromEnum :: Suit -> Int #

enumFrom :: Suit -> [Suit] #

enumFromThen :: Suit -> Suit -> [Suit] #

enumFromTo :: Suit -> Suit -> [Suit] #

enumFromThenTo :: Suit -> Suit -> Suit -> [Suit] #

Eq Suit Source # 
Instance details

Defined in CardParts.Suits

Methods

(==) :: Suit -> Suit -> Bool #

(/=) :: Suit -> Suit -> Bool #

Show Suit Source # 
Instance details

Defined in CardParts.Suits

Methods

showsPrec :: Int -> Suit -> ShowS #

show :: Suit -> String #

showList :: [Suit] -> ShowS #

Generic Suit Source # 
Instance details

Defined in CardParts.Suits

Associated Types

type Rep Suit :: Type -> Type #

Methods

from :: Suit -> Rep Suit x #

to :: Rep Suit x -> Suit #

FromJSON Suit Source # 
Instance details

Defined in CardParts.Suits

Methods

parseJSON :: Value -> Parser Suit

parseJSONList :: Value -> Parser [Suit]

ToJSON Suit Source # 
Instance details

Defined in CardParts.Suits

Methods

toJSON :: Suit -> Value

toEncoding :: Suit -> Encoding

toJSONList :: [Suit] -> Value

toEncodingList :: [Suit] -> Encoding

type Rep Suit Source # 
Instance details

Defined in CardParts.Suits

type Rep Suit = D1 ('MetaData "Suit" "CardParts.Suits" "ofc-calc-haskell-0.1.0.0-inplace" 'False) ((C1 ('MetaCons "Hearts" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Diamonds" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Clubs" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Spades" 'PrefixI 'False) (U1 :: Type -> Type)))

parseSuit :: Char -> Either String Suit Source #

This function gets a char which represents card suit and returns a Suit wrapped with Right.

Char should be a lowercase symbol from "hdcs" list. Otherwise - Left with err msg returns.

Examples:

parseSuit 'h' = Right Hearts
parseSuit 'c' = Right Clubs
parseSuit 'x' = Left "There is no card suit marked as x"