Module

Debug.Trace

Package
purescript-debug
Repository
garyb/purescript-debug

#DebugWarningSource

class DebugWarning 

Nullary class used to raise a custom warning for the debug functions.

Instances

#traceSource

trace :: forall a. DebugWarning => String -> (Unit -> a) -> a

Log a message to the console for debugging purposes and then return a value. The return value is thunked so it is not evaluated until after the message has been printed, to preserve a predictable console output.

For example:

doSomething = trace "Hello" \_ -> ... some value or computation ...

#traceShowSource

traceShow :: forall a b. DebugWarning => Show a => a -> (Unit -> b) -> b

Log a Showable value to the console for debugging purposes and then return a value.

#traceAnySource

traceAny :: forall a b. DebugWarning => a -> (Unit -> b) -> b

Log any PureScript value to the console for debugging purposes and then return a value. This will log the value's underlying representation for low-level debugging.

#spySource

spy :: forall a. DebugWarning => a -> a

Log any value and return it

#traceAnyASource

traceAnyA :: forall a b. DebugWarning => Applicative a => b -> a Unit

Log any PureScript value to the console and return the unit value of the Applicative a.

#traceASource

traceA :: forall a. DebugWarning => Applicative a => String -> a Unit

Log a message to the console for debugging purposes and then return the unit value of the Applicative a.

For example:

doSomething = do
  traceA "Hello"
  ... some value or computation ...

#traceShowASource

traceShowA :: forall a b. DebugWarning => Show b => Applicative a => b -> a Unit

Log a Showable value to the console for debugging purposes and then return the unit value of the Applicative a.

#traceAnyMSource

traceAnyM :: forall m a. DebugWarning => Monad m => a -> m a

Log any PureScript value to the console and return it in Monad useful when one has monadic chains

mbArray :: Maybe (Array Int)
foo :: Int
foo = fromMaybe zero
  $ mbArray
  >>= traceAnyM
  >>= head
  >>= traceAnyM

#traceShowMSource

traceShowM :: forall m a. DebugWarning => Show a => Monad m => a -> m a

Same as traceAnyM but only for Showable values

Modules
Debug.Trace