From: Matthijs Kooijman Date: Wed, 14 Apr 2010 13:16:42 +0000 (+0200) Subject: Add traceIf function for conditional tracing. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=2884f7deed39c010b7c246d164afcf1056588a25;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add traceIf function for conditional tracing. --- diff --git "a/c\316\273ash/CLasH/Utils.hs" "b/c\316\273ash/CLasH/Utils.hs" index 2966757..d85b25b 100644 --- "a/c\316\273ash/CLasH/Utils.hs" +++ "b/c\316\273ash/CLasH/Utils.hs" @@ -7,6 +7,7 @@ import qualified Data.Accessor.Monad.Trans.State as MonadState import qualified Data.Map as Map import qualified Control.Monad as Monad import qualified Control.Monad.Trans.State as State +import qualified Debug.Trace as Trace -- Make a caching version of a stateful computatation. makeCached :: (Monad m, Ord k) => @@ -60,3 +61,9 @@ mapAccumLM f s (x:xs) = do (s', y ) <- f s x (s'', ys) <- mapAccumLM f s' xs return (s'', y:ys) + +-- Trace the given string if the given bool is True, do nothing +-- otherwise. +traceIf :: Bool -> String -> a -> a +traceIf True = Trace.trace +traceIf False = flip const