module Debug.TraceCall.Unsafe where
import Debug.Trace
import Debug.TraceCall.Base
class TCUnsafe a where
tcUnsafe :: TraceData -> Int -> a -> a
instance (Show a) => TCUnsafe a where
tcUnsafe td _ v = trace (traceResult td (show v)) v
instance (TAUnsafe a, TCUnsafe r) => TCUnsafe (a -> r) where
tcUnsafe (TraceData fun as ctx) i f a = tcUnsafe (TraceData fun (as ++ [taUnsafe ("<<function-" ++ show i ++ ">>") a]) ctx) i (f a)
class TAUnsafe a where
taUnsafe :: String -> a -> String
instance (Show a) => TAUnsafe a where
taUnsafe _ = show
instance (TCUnsafe (a -> r)) => TAUnsafe (a -> r) where
taUnsafe s = const s
unsafeTraceCall :: (TCUnsafe a) => String -> a -> a
unsafeTraceCall s f = tcUnsafe (TraceData s [] Nothing) 0 f