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

Debug.Provenance

Description

Utilities for tracking provenance: where and when things are called

Synopsis

Callsites

data CallSite Source #

Callsite

A callsite tells you where something was called: a location in the source, and the name of the function that did the calling. Optionally, they can be given an additional user-defined label also.

NOTE: If you are seeing {unknown} instead of the function name, the calling function does not have a HasCallStack annotation:

yourFunction :: HasCallStack => IO () -- 'HasCallStack' probably missing
yourFunction = do
    let cs = callSite
    ..

Once you add this annotation, you should see yourFunction instead of {unknown}. Similarly, if you have local function definitions, it may be useful to give those HasCallStack constraints of their own:

yourFunction :: HasCallStack => IO ()
yourFunction = ..
  where
    someLocalFn :: HasCallStack => IO ()
    someLocalFn = do
        let cs = callSite
        ..

In this example the HasCallStack constraint on someLocalFn means that the calling function will be reported as someLocalFn instead of yourFunction.

Instances

Instances details
Show CallSite Source # 
Instance details

Defined in Debug.Provenance.Internal

Eq CallSite Source # 
Instance details

Defined in Debug.Provenance.Internal

Hashable CallSite Source # 
Instance details

Defined in Debug.Provenance.Internal

Methods

hashWithSalt :: Int -> CallSite -> Int #

hash :: CallSite -> Int #

prettyCallSite :: CallSite -> String Source #

Render CallSite to human-readable format

callSiteWithLabel :: HasCallStack => String -> CallSite Source #

Current CallSite with user-defined label

Invocations

data Invocation Source #

Invocation

An invocation not only tells you the where, but also the when: it pairs a CallSite with a count, automatically incremented on each call to newInvocation. Each CallSite uses its own counter.

Instances

Instances details
Show Invocation Source # 
Instance details

Defined in Debug.Provenance.Internal

Eq Invocation Source # 
Instance details

Defined in Debug.Provenance.Internal

prettyInvocation :: Invocation -> String Source #

Render Invocation to human-readable format

newInvocation :: (HasCallStack, MonadIO m) => m Invocation Source #

New invocation

See Invocation for discussion.

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