HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleghc-experimental-10.0.0Haskell2010

GHC.Stack.Annotation.Experimental

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).

  • 4 types
  • 1 class
  • 8 values

The root of Stack Annotation Types

1 declaration

Displaying Stack Annotations

1 declaration
classclass StackAnnotation a where
#

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

Methods

Instances4StackAnnotation

Annotation helpers

2 declarations

CallStack annotations

1 declaration

Push stack frame annotations in IO code.

4 declarations

Push stack frame annotations in non-IO code.

4 declarations

These variants all evaluate the code to be annotated to WHNF. Otherwise, the stack annotations will not be shown in stack traces, as the computation is immediately "evaluated" to a thunk, popping the annotation frames from the stack. If the pure computation throws an exception later, the annotation frame will not be present, thus missing in the stack trace.

Note, you will encounter similar issues if the exception is thrown during evaluation of a nested value, for example Just (error "Oh, no!").

valueannotateStack
  1. :: (HasCallStack, Typeable a, StackAnnotation a)
  2. => a
  3. -> b
  4. -> b
#

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.

valueannotateStackString :: HasCallStack => String -> b -> b
#

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.

valueannotateStackShow :: (HasCallStack, Typeable a, Show a) => a -> b -> b
#

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.

valueannotateCallStack :: HasCallStack => b -> b
#

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.