~yoctocell/flaskell

5982e6ed65505ac8c5a0b5d4c6b08b4de97d3933 — yoctocell 1 year, 8 months ago 026fccc
Ui.hs: Add docs
1 files changed, 4 insertions(+), 2 deletions(-)

M src/Flaskell/Ui.hs
M src/Flaskell/Ui.hs => src/Flaskell/Ui.hs +4 -2
@@ 7,10 7,12 @@ feedCards :: [Flashcard] -> IO ()
feedCards []            = return ()
feedCards ((h, a) : cs) = display h a >> feedCards cs

-- | Display hint
-- | Display hint and read guess from stdin.
display :: Hint -> Answer -> IO ()
display h a = putStrLn h >> getLine >>= checkAns h a
display h a = putStrLn ("Hint: " ++ h) >> getLine >>= checkAns h a

-- | Check if guess is correct
-- If incorrect, call @display@ with the same arguments
-- otherwise, continute.
checkAns :: Hint -> Answer -> Guess -> IO ()
checkAns h a guess = if guess == a then return () else display h a