module RPS.Game (
  Hand(..),
  Result(..),
  whoWins,
  whatToDo
) where

data Hand = Rock | Paper | Scissors
  deriving (Show, Eq)
data Result = Win | Lose | Tie

instance Show Result where
  show Win  = "You won! :)"
  show Lose = "You lost! :("
  show Tie  = "Tie -.-"

whoWins :: Hand -> Hand -> Result
whoWins player computer = case (player, computer) of
  (Paper, Rock)     -> Win
  (Rock, Scissors)  -> Win
  (Scissors, Paper) -> Win
  (x, y) | x == y   -> Tie
  (_, _)            -> Lose

whatToDo :: Hand
whatToDo = do
  Rock
