From a97a4cfa0849e91339f13b712da288d54c9dfe46 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 20 Sep 2018 18:32:17 +0000 Subject: [PATCH] Change w output when only one class is possible --- app/Main.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index ba46f75..af03c2f 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -97,10 +97,19 @@ cmdStats = do cmdWhat :: Console () cmdWhat = do g <- lift get - let next = nextGuesses g - showWords = intercalate ", " - showNextGuess (score, w) = numberjust (show score) ++ ": " ++ showWords w - mapM_ (H.outputStrLn . showNextGuess) next + let showWords = intercalate ", " + case possible g of + [ws] -> do + let guesswords = map (\(Guess w _) -> w) $ filter (\(Guess w n) -> n == length w) $ guesses g + possibleWords = ws \\ guesswords + H.outputStrLn "The word is one of the following words:" + H.outputStrLn $ " " ++ showWords possibleWords + H.outputStrLn "These words were already guessed:" + H.outputStrLn $ " " ++ showWords guesswords + _ -> do + let next = nextGuesses g + showNextGuess (score, w) = numberjust (show score) ++ ": " ++ showWords w + mapM_ (H.outputStrLn . showNextGuess) next H.outputStrLn "" loop :: Console ()