module Exercises where import Guitar import Base import Tuning import Tuning.Standard import System.Console.ANSI type Exercise a = Guitar -> a -> IO () playChord :: Exercise Chord playChord g c = do clearScreen >> setCursorPosition 0 0 putStrLn "\nPlay the following chord and press Enter to verify the result:\n" putStrLn $ " " ++ cname c ++ "\n" _ <- getLine putGuitar (displayAt (csquares c) displayPress) g putStr "\nPress Enter to continue: " _ <- getLine return () nameNote :: Exercise Square nameNote g sq = do clearScreen >> setCursorPosition 0 0 let note = show $ pitchClassAt (tuning g) sq putStrLn "\nName the note indicated in the diagram below:\n" putGuitar (displayAt [sq] displayPress) g putStr "Enter the note name and press Enter: " name <- getLine if name == note then putStrLn "\nGood answer!" else putStrLn $ "\nWrong answer: the note is " ++ note putStr "\nPress Enter to continue:" _ <- getLine return () nameChord :: Exercise Chord nameChord g c = do clearScreen >> setCursorPosition 0 0 let chord = takeWhile (/= ' ') $ cname c putStrLn "\nName the chord indicated in the diagram below:\n" putGuitar (displayAt (csquares c) displayPress) g putStr "\nEnter the chord name and press Enter: " name <- getLine if name == chord then putStrLn "\nGood answer!" else putStrLn $ "\nWrong answer: the chord is " ++ chord putStr "\nPress Enter to continue:" _ <- getLine return ()