From 0b87d62ba0573c7ffc50e81e9c98be6647ca2f44 Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 1 Oct 2025 14:24:16 +1000 Subject: [PATCH] refactor: reorder data structures for better readability --- Proj2.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Proj2.hs b/Proj2.hs index be1635b..b0677a3 100644 --- a/Proj2.hs +++ b/Proj2.hs @@ -56,25 +56,26 @@ import Debug.Trace type GameState = [[Pitch]] -data Note = A | B | C | D | E | F | G - deriving (Eq, Show, Ord, Enum, Bounded) - -data Octave = One | Two | Three - deriving (Eq, Ord, Enum, Bounded) - data Pitch = Pitch { note :: Note, octave :: Octave } deriving (Eq, Ord) +instance Show Pitch where + show (Pitch note octave) = show note ++ show octave + +data Note = A | B | C | D | E | F | G + deriving (Bounded, Enum, Eq, Ord, Show) + +data Octave = One | Two | Three + deriving (Bounded, Enum, Eq, Ord) + instance Show Octave where show One = "1" show Two = "2" show Three = "3" -instance Show Pitch where - show (Pitch note octave) = show note ++ show octave -- ==== REQUIRED FUNCTIONS ==================================================== toPitch :: String -> Maybe Pitch