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