Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module contains basic examples advices.
BEWARE! These are provided for illustrative purposes only, they strive for simplicity and not robustness or efficiency.
Synopsis
- returnMempty :: forall ca env m r. (Monad m, Monoid r) => Advice ca env m r
- printArgs :: forall env m r. MonadIO m => Handle -> String -> Advice Show env m r
- type MethodName = String
- type StackFrame = NonEmpty (TypeRep, MethodName)
- type SyntheticCallStack = [StackFrame]
- class HasSyntheticCallStack e where
- callStack :: forall f. Functor f => (SyntheticCallStack -> f SyntheticCallStack) -> e -> f e
- type SyntheticStackTrace = NonEmpty StackFrame
- data SyntheticStackTraceException = SyntheticStackTraceException SomeException SyntheticStackTrace
- keepCallStack :: (MonadUnliftIO m, HasSyntheticCallStack env, Exception e) => (SomeException -> Maybe e) -> NonEmpty (TypeRep, MethodName) -> Advice ca env m r
Basic advices
returnMempty :: forall ca env m r. (Monad m, Monoid r) => Advice ca env m r Source #
Makes functions discard their result and always return mempty
.
Synthetic call stacks
type MethodName = String Source #
type StackFrame = NonEmpty (TypeRep, MethodName) Source #
The typeable representation of the record which contains the invoked function, along with the field name of the invoked function.
type SyntheticCallStack = [StackFrame] Source #
class HasSyntheticCallStack e where Source #
Class of environments that carry a SyntheticCallStack
value that can be
modified.
callStack :: forall f. Functor f => (SyntheticCallStack -> f SyntheticCallStack) -> e -> f e Source #
A lens from the environment to the call stack.
Instances
HasSyntheticCallStack SyntheticCallStack Source # | The trivial case, useful when |
Defined in Dep.SimpleAdvice.Basic callStack :: Functor f => (SyntheticCallStack -> f SyntheticCallStack) -> SyntheticCallStack -> f SyntheticCallStack Source # | |
HasSyntheticCallStack s => HasSyntheticCallStack (Const s x) Source # | |
Defined in Dep.SimpleAdvice.Basic callStack :: Functor f => (SyntheticCallStack -> f SyntheticCallStack) -> Const s x -> f (Const s x) Source # | |
HasSyntheticCallStack s => HasSyntheticCallStack (Constant s x) Source # | |
Defined in Dep.SimpleAdvice.Basic callStack :: Functor f => (SyntheticCallStack -> f SyntheticCallStack) -> Constant s x -> f (Constant s x) Source # |
type SyntheticStackTrace = NonEmpty StackFrame Source #
data SyntheticStackTraceException Source #
Wraps an exception along with a SyntheticCallStack
.
Instances
:: (MonadUnliftIO m, HasSyntheticCallStack env, Exception e) | |
=> (SomeException -> Maybe e) | A selector for the kinds of exceptions we want to catch.
For example |
-> NonEmpty (TypeRep, MethodName) | The path to the current component/method in the environment.
It will be usually obtained through
|
-> Advice ca env m r |
If the environment carries a SyntheticCallStack
, make advised functions add
themselves to the SyntheticCallStack
before they start executing.
Caught exceptions are rethrown wrapped in SyntheticStackTraceException
s,
with the current SyntheticCallStack
added.