X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Debug%2FTrace.hs;h=accf247e882f234fd4eba7da7df0373d059d4490;hb=26d2805a6e58822d246cf9601fb226b0861e7f65;hp=3e369f5e183c12f728ba0b1534276f33a0325310;hpb=66bcbe67b61d83cb01b6d2c876e7b06e034fba88;p=haskell-directory.git diff --git a/Debug/Trace.hs b/Debug/Trace.hs index 3e369f5..accf247 100644 --- a/Debug/Trace.hs +++ b/Debug/Trace.hs @@ -28,7 +28,7 @@ import System.IO (hPutStrLn,stderr) #endif -- | 'putTraceMsg' function outputs the trace message from IO monad. --- Usually the output stream is 'stderr' but if the function is called +-- Usually the output stream is 'System.IO.stderr' but if the function is called -- from Windows GUI application then the output will be directed to the Windows -- debug console. putTraceMsg :: String -> IO () @@ -40,7 +40,8 @@ putTraceMsg msg = do withCString msg $ \cmsg -> debugBelch cfmt cmsg -foreign import ccall unsafe debugBelch :: CString -> CString -> IO () +foreign import ccall unsafe "RtsMessages.h debugBelch" + debugBelch :: CString -> CString -> IO () #endif {-# NOINLINE trace #-} @@ -56,3 +57,11 @@ trace :: String -> a -> a trace string expr = unsafePerformIO $ do putTraceMsg string return expr + +{-| +Like 'trace', but uses 'show' on the argument to convert it to a 'String'. + +> traceShow = trace . show +-} +traceShow :: (Show a) => a -> b -> b +traceShow = trace . show