@@ -14,6 +14,7 @@ import Education.MakeMistakesToLearnHaskell.Error
14
14
import Education.MakeMistakesToLearnHaskell.Text
15
15
16
16
import qualified Options.Applicative as Opt
17
+ import System.Console.ANSI
17
18
18
19
main :: IO ()
19
20
main = do
@@ -83,17 +84,15 @@ verifySource e (file : _) = do
83
84
case result of
84
85
Exercise. Success details -> do
85
86
Text. putStrLn details
86
- putStrLn " \n\n SUCCESS: Congratulations! Your solution got compiled and ran correctly!"
87
+ withSGR [SetColor Foreground Vivid Green ] $
88
+ putStrLn " \n\n SUCCESS: Congratulations! Your solution got compiled and ran correctly!"
87
89
putStrLn " Here's an example solution of this exercise:\n "
88
90
Text. putStr =<< Exercise. loadExampleSolution currentExercise
89
91
Exit. exitSuccess
90
92
Exercise. Fail details -> do
91
- mapM_ Text. putStrLn
92
- [ details
93
- , " "
94
- , " FAIL: Your solution didn't pass. Try again!"
95
- , " "
96
- ]
93
+ Text. putStrLn details
94
+ withSGR [SetColor Foreground Vivid Red ] $
95
+ putStrLn " \n FAIL: Your solution didn't pass. Try again!\n "
97
96
Exit. exitFailure
98
97
Exercise. Error details -> do
99
98
Error. errLn $ Text. toStrict $ details <> " \n\n "
@@ -106,6 +105,8 @@ verifySource e (file : _) = do
106
105
putStrLn " Here's an example solution of this exercise:\n "
107
106
Text. putStr =<< Exercise. loadExampleSolution currentExercise
108
107
Exit. exitSuccess
108
+ where
109
+ withSGR sgrs act = setSGR sgrs >> act >> setSGR [Reset ]
109
110
110
111
111
112
showExercise :: Env -> Bool -> [String ] -> IO ()
0 commit comments