debuggable-0.1.0: Utilities for making your applications more debuggable.
Safe HaskellNone
LanguageHaskell2010

Debug.Provenance.Callback

Description

Provenance for callbacks

Synopsis

Callbacks

data Callback (m :: Type -> Type) a b Source #

Callback of type (a -> m b)

When we invoke a callback, it is useful to distinguish between two things:

  • The CallStack of the invocation of the callback
  • The CallSite of the definition of the callback

The purpose of this module is to be careful about this distinction; a HasCallStack backtrace originating from an invocation of a callback will look something like this:

gM, called at ..
..
g2, called at ..
g1, called at ..
callbackFn, called at ..
invoking callback defined at <callSite>
invokeCallback, called at ..
fN, called at ..
..
f2, called at ..
f1, called at ..

where

  • f1 .. fN are the function calls leading up to the callback
  • g1 .. gM are the function calls made inside of the callback
  • <callSite> tells us where the callback was defined

callback :: HasCallStack => (HasCallStack => a -> m b) -> Callback m a b Source #

Define Callback

See Callback for discussion and motivation of the two HasCallStack constraints.

invokeCallback :: HasCallStack => Callback m a b -> a -> m b Source #

Invoke Callback

Convenience re-exports

type HasCallStack = ?callStack :: CallStack #

Request a CallStack.

NOTE: The implicit parameter ?callStack :: CallStack is an implementation detail and should not be considered part of the CallStack API, we may decide to change the implementation in the future.

@since base-4.9.0.0