HORIZON HASKELLDocslts/ghc-10.0.x04404a62026-10-19Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 04404a6 · 2026-10-19

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

Contents
  1. The root of Stack Annotation Types
  2. Displaying Stack Annotations
  3. Annotation helpers
  4. CallStack annotations
  5. Push stack frame annotations in IO code.
  6. Push stack frame annotations in non-IO code.
Synopsis

The root of Stack Annotation Types

Displaying Stack Annotations

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

CallStack annotations

Push stack frame annotations in IO code.

Push stack frame annotations in non-IO code.

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

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.