Skip to content
  • Ben Gamari's avatar
    774fec37
    Add primop to annotate the call stack with arbitrary data · 774fec37
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    
    
    We introduce a new primop `annotateStack#` which allows us to push
    arbitrary data onto the call-stack.
    This allows us to extract the data later when decoding the stack, for
    example when an exception is thrown, showing more information to the
    user without having to annotate the full call-stack with `HasCallStack`
    constraints.
    
    A new stack frame value is introduced `AnnFrame`, which consists of
    nothing but a generic payload.
    
    The primop has a small wrapper API that allows users to annotate their
    call-stack in programs.
    There is a pure API and an IO-based one. The former is a little bit
    dubious, as it affects the evaluation of a program, so use with care.
    The latter is "safe", as it doesn't change the evaluation of the
    program.
    
    The stack annotation mechanism is similarly implemented to the
    `ExceptionAnnotation` and `Exception`, there is a typeclass to indicate
    something can be pushed onto the call-stack and all values are wrapped
    in the existential `SomeStackAnnotation`, which recover the type of the
    annotation payload.
    
    There is currently no builtin way to show the stack annotations when
    `Backtraces` are displayed (i.e., when showing stack traces to the user),
    which we will address in a follow-up MR.
    
    -------------------------
    Metric Increase:
        ghc_experimental_so
    -------------------------
    
    We increase the size of the package, so this is not unreasonable.
    
    Co-Authored-By: default avatarfendor <fendor@posteo.de>
    Co-Authored-By: default avatarBen Gamari <bgamari.foss@gmail.com>
    774fec37
    Add primop to annotate the call stack with arbitrary data
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    
    
    We introduce a new primop `annotateStack#` which allows us to push
    arbitrary data onto the call-stack.
    This allows us to extract the data later when decoding the stack, for
    example when an exception is thrown, showing more information to the
    user without having to annotate the full call-stack with `HasCallStack`
    constraints.
    
    A new stack frame value is introduced `AnnFrame`, which consists of
    nothing but a generic payload.
    
    The primop has a small wrapper API that allows users to annotate their
    call-stack in programs.
    There is a pure API and an IO-based one. The former is a little bit
    dubious, as it affects the evaluation of a program, so use with care.
    The latter is "safe", as it doesn't change the evaluation of the
    program.
    
    The stack annotation mechanism is similarly implemented to the
    `ExceptionAnnotation` and `Exception`, there is a typeclass to indicate
    something can be pushed onto the call-stack and all values are wrapped
    in the existential `SomeStackAnnotation`, which recover the type of the
    annotation payload.
    
    There is currently no builtin way to show the stack annotations when
    `Backtraces` are displayed (i.e., when showing stack traces to the user),
    which we will address in a follow-up MR.
    
    -------------------------
    Metric Increase:
        ghc_experimental_so
    -------------------------
    
    We increase the size of the package, so this is not unreasonable.
    
    Co-Authored-By: default avatarfendor <fendor@posteo.de>
    Co-Authored-By: default avatarBen Gamari <bgamari.foss@gmail.com>
Loading