1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
module Output where
import IO (hPutStrLn, stderr)
import List (intercalate)
import System (exitWith)
import Unsafe (unsafePerformIO)
import PevalOpts (Options (..), ColorMode (..), Verbosity (..))
traceDetail :: Options -> String -> a -> a
traceDetail o m x = unsafePerformIO (detail o m >> return x)
traceDebug :: Options -> String -> a -> a
traceDebug o m x = unsafePerformIO (debug o m >> return x)
status :: Options -> String -> IO ()
status opts msg = when (optVerbosity opts >= Status) (putStrLn msg)
info :: Options -> String -> IO ()
info opts msg = when (optVerbosity opts >= Info) (putStrLn msg)
detail :: Options -> String -> IO ()
detail opts msg = when (optVerbosity opts >= Detail) (putStrLn msg)
debug :: Options -> String -> IO ()
debug opts msg = when (optVerbosity opts >= Debug) (putStrLn msg)
assert :: Bool -> String -> a -> a
assert b m x = if b then x
else unsafePerformIO (hPutStrLn stderr err >> exitWith 1)
where err = "Assertion failed: " ++ m
colorWith :: Options -> (String -> String) -> String -> String
colorWith opts color s = if optColorMode opts == CMAlways then color s else s
|