Cleanup Day1 types

This commit is contained in:
Jens Kadenbach
2022-12-02 11:53:44 +01:00
parent 2f60058c6c
commit 024edd3e9d
4 changed files with 34 additions and 40 deletions

View File

@@ -18,22 +18,10 @@ import qualified Data.List as L
import Data.Either
newtype CalorieCount = CalorieCount Int
deriving (Show, Eq, Ord)
newtype Elf = Elf CalorieCount
instance Show CalorieCount where
show (CalorieCount c) = "Calories[" ++ show c ++ "]"
instance Show Elf where
show (Elf (CalorieCount c)) = "Elf[" ++ show c ++ "]"
instance Eq CalorieCount where
(==) (CalorieCount c1) (CalorieCount c2) = c1 == c2
instance Eq Elf where
(==) (Elf (CalorieCount c1)) (Elf (CalorieCount c2)) = c1 == c2
instance Ord Elf where
compare (Elf (CalorieCount c1)) (Elf (CalorieCount c2)) = compare c1 c2
deriving (Show, Eq, Ord)
elf :: Int -> Elf
elf c = Elf (CalorieCount c)