module ClientMessages (
                       CmdMsg(..)
                      ) where

-- | Valid commands to be sent to the rover
data CmdMsg =
    NullCmd |
    AccelCmd |
    BrakeCmd |
    LeftCmd |
    RightCmd |
    AccelLeftCmd |
    AccelRightCmd |
    BrakeLeftCmd |
    BrakeRightCmd
    deriving (Read, Eq)

-- Show produces proper output for transmission to Mars
instance Show CmdMsg where
    show c = case c of
               NullCmd -> ""
               AccelCmd -> "a"
               BrakeCmd -> "b"
               LeftCmd -> "l"
               RightCmd -> "r"
               AccelLeftCmd -> "al"
               AccelRightCmd -> "ar"
               BrakeLeftCmd -> "bl"
               BrakeRightCmd -> "br"
    showList l = showString $
                     foldr (\x y -> x ++ ";" ++ y) "" (map show l)
