feat: implement toPitch
This commit is contained in:
parent
9419d0d25b
commit
00e2dae6c1
1 changed files with 23 additions and 1 deletions
24
Proj2.hs
24
Proj2.hs
|
|
@ -33,7 +33,29 @@ instance Show Pitch where
|
||||||
show (Pitch note octave) = show note ++ show octave
|
show (Pitch note octave) = show note ++ show octave
|
||||||
|
|
||||||
toPitch :: String -> Maybe Pitch
|
toPitch :: String -> Maybe Pitch
|
||||||
toPitch _ = Just (Pitch 'A' 1)
|
toPitch [note, octave] = Pitch <$> charToNote note <*> charToOctave octave
|
||||||
|
where
|
||||||
|
charToNote :: Char -> Maybe Note
|
||||||
|
charToNote c =
|
||||||
|
lookup
|
||||||
|
c
|
||||||
|
[ ('A', A),
|
||||||
|
('B', B),
|
||||||
|
('C', C),
|
||||||
|
('D', D),
|
||||||
|
('E', E),
|
||||||
|
('F', F),
|
||||||
|
('G', G)
|
||||||
|
]
|
||||||
|
charToOctave :: Char -> Maybe Octave
|
||||||
|
charToOctave c =
|
||||||
|
lookup
|
||||||
|
c
|
||||||
|
[ ('1', One),
|
||||||
|
('2', Two),
|
||||||
|
('3', Three)
|
||||||
|
]
|
||||||
|
toPitch _ = Nothing
|
||||||
|
|
||||||
feedback :: [Pitch] -> [Pitch] -> (Int, Int, Int)
|
feedback :: [Pitch] -> [Pitch] -> (Int, Int, Int)
|
||||||
feedback _ _ = (0, 0, 0)
|
feedback _ _ = (0, 0, 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue