ghc-experimental-9.1500.0: Experimental features of GHC's standard library
Copyright(c) The GHC Team
Licensesee libraries/ghc-experimental/LICENSE
Maintainerghc-devs@haskell.org
Stabilityexperimental
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone
LanguageHaskell2010

GHC.Stack.Annotation.Experimental

Description

Push user-defined annotation stack frames into the Haskell call stack. Annotation stack frames may be decoded when unwinding the call stack, allowing the user to gain more control over what an IPE stack trace looks like.

The main advantages of stack frame annotations over other Backtraces: * Function signatures don't need to be modified to improve stack traces (e.g. via HasCallStack). * Annotation are arbitrary user-defined datatypes, not just source locations. * Stack frame annotations are always present and do not require recompilation (e.g. -prof or -g3).

Synopsis

The root of Stack Annotation Types

data SomeStackAnnotation where Source #

The SomeStackAnnotation type is the root of the stack annotation type hierarchy. When the call stack is annotated with a value of type a, behind the scenes it is encapsulated in a SomeStackAnnotation.

Constructors

SomeStackAnnotation :: forall a. (Typeable a, StackAnnotation a) => a -> SomeStackAnnotation 

Displaying Stack Annotations

class StackAnnotation a where Source #

StackAnnotations are types which can be pushed onto the call stack as the payload of AnnFrame stack frames.

Annotation helpers

data ShowAnnotation where Source #

Use the Show instance of a type to display as the StackAnnotation.

Constructors

ShowAnnotation :: forall a. Show a => a -> ShowAnnotation 

CallStack annotations

Push stack frame annotations in IO code.

annotateStackIO :: (Typeable a, StackAnnotation a) => a -> IO b -> IO b Source #

annotateStackIO showable b annotates the evaluation stack of b with the value showable.

When decoding the call stack, the annotation frames can be used to add more information to stack traces.

annotateStackStringIO :: String -> IO b -> IO b Source #

annotateStackStringIO msg b annotates the evaluation stack of b with the value msg.

When decoding the call stack, the annotation frames can be used to add more information to stack traces.

annotateStackShowIO :: Show a => a -> IO b -> IO b Source #

annotateStackShowIO msg b annotates the evaluation stack of b with the value msg.

When decoding the call stack, the annotation frames can be used to add more information to stack traces.

annotateCallStackIO :: HasCallStack => IO a -> IO a Source #

annotateCallStackIO b annotates the evaluation stack of b with the current callstack.

When decoding the call stack, the annotation frames can be used to add more information to stack traces.

Push stack frame annotations in non-IO code.

annotateStack :: (Typeable a, StackAnnotation a) => a -> b -> b Source #

annotateStack anno b annotates the evaluation stack of b with the value of anno.

When decoding the call stack, the annotation frames can be used to add more information to stack traces.

WARNING: forces the evaluation of b to WHNF.

annotateStackString :: String -> b -> b Source #

annotateStackString msg b annotates the evaluation stack of b with the value msg.

When decoding the call stack, the annotation frames can be used to add more information to stack traces.

WARNING: forces the evaluation of b to WHNF.

annotateStackShow :: (Typeable a, Show a) => a -> b -> b Source #

annotateStackShow showable b annotates the evaluation stack of b with the value showable.

When decoding the call stack, the annotation frames can be used to add more information to stack traces.

WARNING: forces the evaluation of b to WHNF.

annotateCallStack :: HasCallStack => b -> b Source #

annotateCallStack b annotates the evaluation stack of b with the current callstack.

When decoding the call stack, the annotation frames can be used to add more information to stack traces.

WARNING: forces the evaluation of b to WHNF.