From: Neil Smith <NeilNjae@users.noreply.github.com>
Date: Sat, 3 Dec 2022 08:29:04 +0000 (+0000)
Subject: Using bounded
X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-22.git;a=commitdiff_plain;h=ec5050108d9c636018dabb874aae6114ce59b5c2

Using bounded
---

diff --git a/advent02/Main.hs b/advent02/Main.hs
index 9cb89cc..44a2361 100644
--- a/advent02/Main.hs
+++ b/advent02/Main.hs
@@ -6,7 +6,7 @@ import qualified Data.Text.IO as TIO
 import Data.Attoparsec.Text hiding (Result)
 import Control.Applicative
 
-data Shape = Rock | Paper | Scissors deriving (Show, Eq, Ord, Enum)
+data Shape = Rock | Paper | Scissors deriving (Show, Eq, Ord, Enum, Bounded)
 data Result = Loss | Draw | Win deriving (Show, Eq, Ord, Enum)
 data Round = Round Shape Shape deriving (Eq, Show)
 data ShapeResult = ShapeResult Shape Result deriving (Eq, Show)
@@ -55,7 +55,8 @@ scoreResult r = 3 * fromEnum r
 roundFromResult :: ShapeResult -> Round
 roundFromResult (ShapeResult shape result) = Round shape p2s
   where p2s = head [ p2Shape 
-                   | p2Shape <- [Rock .. Scissors]
+                   -- | p2Shape <- [Rock .. Scissors]
+                   | p2Shape <- [minBound .. maxBound]
                    , player2Result (Round shape p2Shape) == result
                    ]