Trace instrumentation #
Writer-valued instrumentation records query-dependent observations before a handler runs, or response-dependent observations after a response returns. Projection recovers the original computation for any lawful base monad.
withTraceBefore: response-independent trace, recorded before handler #
Wrap an oracle implementation so that each query records traceFn t in
the writer ω before running the handler. The trace value depends only on
the query. Failure in the base monad can discard the entire writer result.
Instances For
When every query traces to the monoid identity 1, withTraceBefore is a
no-op up to pairing with 1.
Wrap an oracle implementation so that each query records
traceFn t u in the writer ω after the handler returns response u.
A handler failure skips the trace (the response never materialised).
Instances For
When every query/response pair traces to the monoid identity 1,
withTrace is a no-op up to pairing with 1.
withTraceAppendBefore: response-independent trace, recorded before #
handler, accumulating via ∅ / ++
Append-flavoured analogue of withTraceBefore: each query records
traceFn t in the writer ω before running the handler, and WriterT
uses the [EmptyCollection ω] [Append ω] Monad instance (tell is a single
push, bind concatenates with ++). The trace value depends only on the
query. Failure in the base monad can discard the entire writer result.
Instances For
withTraceAppend: response-dependent trace, recorded after handler, #
accumulating via ∅ / ++
Append-flavoured analogue of withTrace: each query records
traceFn t u in the writer ω after the handler returns response u,
using the [EmptyCollection ω] [Append ω] Monad (WriterT ω m) instance.
A handler failure skips the trace (the response never materialised).