refactor: reorder data structures for better readability

This commit is contained in:
wi11-holdsworth 2025-10-01 14:24:16 +10:00
parent df8bd3290f
commit 0b87d62ba0

View file

@ -56,25 +56,26 @@ import Debug.Trace
type GameState = [[Pitch]] 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 data Pitch = Pitch
{ note :: Note, { note :: Note,
octave :: Octave octave :: Octave
} }
deriving (Eq, Ord) 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 instance Show Octave where
show One = "1" show One = "1"
show Two = "2" show Two = "2"
show Three = "3" show Three = "3"
instance Show Pitch where
show (Pitch note octave) = show note ++ show octave
-- ==== REQUIRED FUNCTIONS ==================================================== -- ==== REQUIRED FUNCTIONS ====================================================
toPitch :: String -> Maybe Pitch toPitch :: String -> Maybe Pitch