base-compat-0.13.1: A compatibility layer for base
Safe HaskellSafe-Inferred
LanguageHaskell2010

Debug.Trace.Compat

Synopsis

Documentation

traceId :: String -> String #

Like trace but returns the message instead of a third value.

>>> traceId "hello"
hello
"hello"

Since: base-4.7.0.0

traceShowId :: Show a => a -> a #

Like traceShow but returns the shown value instead of a third value.

>>> traceShowId (1+2+3, "hello" ++ "world")
(6,"helloworld")
(6,"helloworld")

Since: base-4.7.0.0

traceM :: Applicative f => String -> f () #

Like trace but returning unit in an arbitrary Applicative context. Allows for convenient use in do-notation.

Note that the application of traceM is not an action in the Applicative context, as traceIO is in the IO type. While the fresh bindings in the following example will force the traceM expressions to be reduced every time the do-block is executed, traceM "not crashed" would only be reduced once, and the message would only be printed once. If your monad is in MonadIO, liftIO . traceIO may be a better option.

>>> :{
do
    x <- Just 3
    traceM ("x: " ++ show x)
    y <- pure 12
    traceM ("y: " ++ show y)
    pure (x*2 + y)
:}
x: 3
y: 12
Just 18

Since: base-4.7.0.0

traceShowM :: (Show a, Applicative f) => a -> f () #

Like traceM, but uses show on the argument to convert it to a String.

>>> :{
do
    x <- Just 3
    traceShowM x
    y <- pure 12
    traceShowM y
    pure (x*2 + y)
:}
3
12
Just 18

Since: base-4.7.0.0

traceWith :: (a -> String) -> a -> a Source #

Like trace, but outputs the result of calling a function on the argument.

>>> traceWith fst ("hello","world")
hello
("hello","world")

Since: 4.18.0.0

traceShowWith :: Show b => (a -> b) -> a -> a Source #

Like traceWith, but uses show on the result of the function to convert it to a String.

>>> traceShowWith length [1,2,3]
3
[1,2,3]

Since: 4.18.0.0

traceEventWith :: (a -> String) -> a -> a Source #

Like traceEvent, but emits the result of calling a function on its argument.

Since: 4.18.0.0