From 00e2dae6c1ab1a091fd16750c05a15666feabe3f Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 24 Sep 2025 14:53:50 +1000 Subject: [PATCH] feat: implement toPitch --- Proj2.hs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Proj2.hs b/Proj2.hs index 2e23371..a9d30b6 100644 --- a/Proj2.hs +++ b/Proj2.hs @@ -33,7 +33,29 @@ instance Show Pitch where show (Pitch note octave) = show note ++ show octave 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 _ _ = (0, 0, 0)