1 | {-# LANGUAGE CPP #-} |
2 | |
3 | module Clash.Debug |
4 | ( debugIsOn |
5 | , traceIf |
6 | , traceWith |
7 | , traceShowWith |
8 | , module Debug.Trace |
9 | ) where |
10 | |
11 | import Debug.Trace |
12 | |
13 | debugIsOn :: Bool |
14 | #if defined(DEBUG) |
15 | debugIsOn = True |
16 | #else |
17 | debugIsOn = False |
18 | #endif |
19 | |
20 | -- | Performs trace when first argument evaluates to 'True' |
21 | traceIf :: Bool -> String -> a -> a |
22 | traceIf True msg = trace msg |
23 | traceIf False _ = id |
24 | {-# INLINE traceIf #-} |
25 | |
26 | traceWith :: (a -> String) -> a -> a |
27 | traceWith f a = trace (f a) a |
28 | |
29 | traceShowWith :: Show b => (a -> b) -> a -> a |
30 | traceShowWith f a = trace (show (f a)) a |