| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ide.Plugin.Tactic.Debug
Synopsis
- unsafeRender :: Outputable a => a -> String
- unsafeRender' :: SDoc -> String
- traceM :: Applicative f => String -> f ()
- traceShowId :: Show a => a -> a
- trace :: String -> a -> a
- traceX :: Show a => String -> a -> b -> b
- traceIdX :: Show a => String -> a -> a
- traceMX :: (Monad m, Show a) => String -> a -> m ()
- traceFX :: String -> (a -> String) -> a -> a
Documentation
unsafeRender :: Outputable a => a -> String Source #
Print something
unsafeRender' :: SDoc -> String Source #
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,
may be a better option.liftIO . traceIO
>>>:{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
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
The trace function outputs the trace message given as its first argument,
before returning the second argument as its result.
For example, this returns the value of f x but first outputs the message.
>>>let x = 123; f = show>>>trace ("calling f with x = " ++ show x) (f x)"calling f with x = 123 123"
The trace function should only be used for debugging, or for monitoring
execution. The function is not referentially transparent: its type indicates
that it is a pure function but it has the side effect of outputting the
trace message.