ofc-calc-haskell-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

CardParts.Values

Description

Card value data type and its processing functions

Synopsis

Documentation

data Value Source #

This type represents card value.

Constructors

Two 
Three 
Four 
Five 
Six 
Seven 
Eight 
Nine 
Ten 
Jack 
Queen 
King 
Ace 

Instances

Instances details
Bounded Value Source # 
Instance details

Defined in CardParts.Values

Enum Value Source # 
Instance details

Defined in CardParts.Values

Eq Value Source # 
Instance details

Defined in CardParts.Values

Methods

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

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

Ord Value Source # 
Instance details

Defined in CardParts.Values

Methods

compare :: Value -> Value -> Ordering #

(<) :: Value -> Value -> Bool #

(<=) :: Value -> Value -> Bool #

(>) :: Value -> Value -> Bool #

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

max :: Value -> Value -> Value #

min :: Value -> Value -> Value #

Show Value Source # 
Instance details

Defined in CardParts.Values

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

Generic Value Source # 
Instance details

Defined in CardParts.Values

Associated Types

type Rep Value :: Type -> Type #

Methods

from :: Value -> Rep Value x #

to :: Rep Value x -> Value #

FromJSON Value Source # 
Instance details

Defined in CardParts.Values

Methods

parseJSON :: Value0 -> Parser Value

parseJSONList :: Value0 -> Parser [Value]

ToJSON Value Source # 
Instance details

Defined in CardParts.Values

Methods

toJSON :: Value -> Value0

toEncoding :: Value -> Encoding

toJSONList :: [Value] -> Value0

toEncodingList :: [Value] -> Encoding

type Rep Value Source # 
Instance details

Defined in CardParts.Values

type Rep Value = D1 ('MetaData "Value" "CardParts.Values" "ofc-calc-haskell-0.1.0.0-inplace" 'False) (((C1 ('MetaCons "Two" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Three" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Four" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Five" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Six" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Seven" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "Eight" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Nine" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Ten" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Jack" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Queen" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "King" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Ace" 'PrefixI 'False) (U1 :: Type -> Type)))))

parseValue :: Char -> ValueResult Source #

This function gets a char which represents card value and returns a Value wrapped with Maybe.

Char should be a digit between 2 and 9 or an uppercase symbol from [AKQJT] list. Otherwise - Nothing returns.

Examples:

parseValue '2' = Right Two
parseValue 'Q' = Right Queen
parseValue 'z' = Left "There is no broadway card, which could be represented with 'z'"
parseValue '1' = Left "There is no number card with value 1"