module Diplomacy.Unit (
Unit(..)
, parseUnit
, printUnit
) where
import Control.Applicative
import Data.String (IsString)
import Text.Parsec hiding ((<|>))
import Text.Parsec.Text
data Unit where
Army :: Unit
Fleet :: Unit
deriving instance Eq Unit
deriving instance Ord Unit
deriving instance Show Unit
deriving instance Enum Unit
deriving instance Bounded Unit
parseUnit :: Parser Unit
parseUnit = parseFleet <|> parseArmy
where
parseFleet :: Parser Unit
parseFleet = (char 'F' <|> char 'f') *> pure Fleet
parseArmy :: Parser Unit
parseArmy = (char 'A' <|> char 'a') *> pure Army
printUnit :: IsString a => Unit -> a
printUnit unit = case unit of
Army -> "A"
Fleet -> "F"