refactor: improve flow of file by ordering functions better

This commit is contained in:
wi11-holdsworth 2025-09-25 11:52:37 +10:00
parent e26b60a9ed
commit e9710a5bf8

View file

@ -13,6 +13,8 @@ where
import Data.List
import Data.Set qualified as S
-- datatypes --
type GameState = [[Pitch]]
data Note = A | B | C | D | E | F | G
@ -35,6 +37,10 @@ instance Show Octave where
instance Show Pitch where
show (Pitch note octave) = show note ++ show octave
--
-- required functions --
toPitch :: String -> Maybe Pitch
toPitch [note, octave] = Pitch <$> charToNote note <*> charToOctave octave
where
@ -83,6 +89,14 @@ initialGuess = (chord, chords)
where
chord : chords = allChords
-- implement me
nextGuess :: ([Pitch], GameState) -> (Int, Int, Int) -> ([Pitch], GameState)
nextGuess (prevGuess, chord : chords) _ = (chord, chords)
--
-- helper functions --
allChords :: [[Pitch]]
allChords =
[ chord
@ -108,6 +122,4 @@ allOctaves = [minBound .. maxBound]
allNotes :: [Note]
allNotes = [minBound .. maxBound]
-- implement me
nextGuess :: ([Pitch], GameState) -> (Int, Int, Int) -> ([Pitch], GameState)
nextGuess (prevGuess, chord : chords) _ = (chord, chords)
--