refactor: improve flow of file by ordering functions better
This commit is contained in:
parent
e26b60a9ed
commit
e9710a5bf8
1 changed files with 15 additions and 3 deletions
18
Proj2.hs
18
Proj2.hs
|
|
@ -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)
|
||||
--
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue