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