File: .lake/packages/lean4/src/lean/Lean/Util/Trace.lean

full_name: Lean.instInhabitedTraceElem
code: structure TraceElem where
  ref : Syntax
  msg : MessageData
  deriving Inhabited
goal: Inhabited Lean.TraceElem

full_name: Lean.TraceElem.msg
code: structure TraceElem where
  ref : Syntax
  msg : MessageData
  deriving Inhabited
goal: Lean.MessageData

full_name: Lean.TraceElem.ref
code: structure TraceElem where
  ref : Syntax
  msg : MessageData
  deriving Inhabited
goal: Lean.Syntax

full_name: Lean.TraceElem
code: structure TraceElem where
  ref : Syntax
  msg : MessageData
  deriving Inhabited
goal: Type

full_name: Lean.instInhabitedTraceState
code: structure TraceState where
  traces  : PersistentArray TraceElem := {}
  deriving Inhabited
goal: Inhabited Lean.TraceState

full_name: Lean.TraceState.traces
code: structure TraceState where
  traces  : PersistentArray TraceElem := {}
  deriving Inhabited
goal: Lean.PersistentArray Lean.TraceElem

full_name: Lean.TraceState
code: structure TraceState where
  traces  : PersistentArray TraceElem := {}
  deriving Inhabited
goal: Type

full_name: Lean.inheritedTraceOptions
code: builtin_initialize inheritedTraceOptions : IO.Ref (HashSet Name) ← IO.mkRef ∅
goal: IO.Ref (Lean.HashSet Lean.Name)

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.Util.Trace._hyg.66
code: builtin_initialize inheritedTraceOptions : IO.Ref (HashSet Name) ← IO.mkRef ∅
goal: IO (IO.Ref (Lean.HashSet Lean.Name))

full_name: Lean.MonadTrace.getTraceState
code: class MonadTrace (m : Type → Type) where
  modifyTraceState : (TraceState → TraceState) → m Unit
  getTraceState    : m TraceState
goal: m Lean.TraceState

full_name: Lean.MonadTrace
code: class MonadTrace (m : Type → Type) where
  modifyTraceState : (TraceState → TraceState) → m Unit
  getTraceState    : m TraceState
goal: Type

full_name: Lean.MonadTrace.modifyTraceState
code: class MonadTrace (m : Type → Type) where
  modifyTraceState : (TraceState → TraceState) → m Unit
  getTraceState    : m TraceState
goal: (Lean.TraceState → Lean.TraceState) → m Unit

full_name: Lean.instMonadTraceOfMonadLift
code: instance (m n) [MonadLift m n] [MonadTrace m] : MonadTrace n 
goal: Lean.MonadTrace n

full_name: Lean.printTraces
code: def printTraces : m Unit 
goal: m Unit

full_name: Lean.resetTraceState
code: def resetTraceState : m Unit 
goal: m Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Util.Trace.0.Lean.checkTraceOption.go
code: private def checkTraceOption (inherited : HashSet Name) (opts : Options) (cls : Name) : Bool 
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Util.Trace.0.Lean.checkTraceOption
code: private def checkTraceOption (inherited : HashSet Name) (opts : Options) (cls : Name) : Bool 
goal: Bool

full_name: Lean.isTracingEnabledFor
code: def isTracingEnabledFor (cls : Name) : m Bool 
goal: m Bool

full_name: Lean.getTraces
code: @[inline] def getTraces : m (PersistentArray TraceElem) 
goal: m (Lean.PersistentArray Lean.TraceElem)

full_name: Lean.modifyTraces
code: @[inline] def modifyTraces (f : PersistentArray TraceElem → PersistentArray TraceElem) : m Unit 
goal: m Unit

full_name: Lean.setTraceState
code: @[inline] def setTraceState (s : TraceState) : m Unit 
goal: m Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Util.Trace.0.Lean.getResetTraces
code: private def getResetTraces : m (PersistentArray TraceElem) 
goal: m (Lean.PersistentArray Lean.TraceElem)

full_name: Lean.addRawTrace
code: def addRawTrace (msg : MessageData) : m Unit 
goal: m Unit

full_name: Lean.addTrace
code: def addTrace (cls : Name) (msg : MessageData) : m Unit 
goal: m Unit

full_name: Lean.trace
code: @[inline] def trace (cls : Name) (msg : Unit → MessageData) : m Unit 
goal: m Unit

full_name: Lean.traceM
code: @[inline] def traceM (cls : Name) (mkMsg : m MessageData) : m Unit 
goal: m Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Util.Trace.0.Lean.addTraceNode
code: private def addTraceNode (oldTraces : PersistentArray TraceElem)
    (data : TraceData) (ref : Syntax) (msg : MessageData) : m Unit 
goal: m Unit

full_name: Lean.trace.profiler
code: register_builtin_option trace.profiler : Bool := {
  defValue := false
  group    := "profiler"
  descr    :=
    "activate nested traces with execution time above `trace.profiler.threshold` and annotate with \
    time"
}
goal: Lean.Option Bool

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.Util.Trace._hyg.1239
code: register_builtin_option trace.profiler : Bool := {
  defValue := false
  group    := "profiler"
  descr    :=
    "activate nested traces with execution time above `trace.profiler.threshold` and annotate with \
    time"
}
goal: IO (Lean.Option Bool)

full_name: Lean.trace.profiler.threshold
code: register_builtin_option trace.profiler.threshold : Nat := {
  defValue := 10
  group    := "profiler"
  descr    :=
    "threshold in milliseconds (or heartbeats if `trace.profiler.useHeartbeats` is true), \
    traces below threshold will not be activated"
}
goal: Lean.Option Nat

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.Util.Trace._hyg.1333
code: register_builtin_option trace.profiler.threshold : Nat := {
  defValue := 10
  group    := "profiler"
  descr    :=
    "threshold in milliseconds (or heartbeats if `trace.profiler.useHeartbeats` is true), \
    traces below threshold will not be activated"
}
goal: IO (Lean.Option Nat)

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.Util.Trace._hyg.1427
code: register_builtin_option trace.profiler.useHearbeats : Bool := {
  defValue := false
  group    := "profiler"
  descr    :=
    "if true, measure and report heartbeats instead of seconds"
}
goal: IO (Lean.Option Bool)

full_name: Lean.trace.profiler.useHearbeats
code: register_builtin_option trace.profiler.useHearbeats : Bool := {
  defValue := false
  group    := "profiler"
  descr    :=
    "if true, measure and report heartbeats instead of seconds"
}
goal: Lean.Option Bool

full_name: Lean.trace.profiler.output
code: register_builtin_option trace.profiler.output : String := {
  defValue := ""
  group    := "profiler"
  descr    :=
    "output `trace.profiler` data in Firefox Profiler-compatible format to given file path"
}
goal: Lean.Option String

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.Util.Trace._hyg.1521
code: register_builtin_option trace.profiler.output : String := {
  defValue := ""
  group    := "profiler"
  descr    :=
    "output `trace.profiler` data in Firefox Profiler-compatible format to given file path"
}
goal: IO (Lean.Option String)

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.Util.Trace._hyg.1615
code: register_builtin_option trace.profiler.output.pp : Bool := {
  defValue := false
  group    := "profiler"
  descr    :=
    "if false, limit text in exported trace nodes to trace class name and `TraceData.tag`, if any

This is useful when we are interested in the time taken by specific subsystems instead of specific \
invocations, which is the common case."
}
goal: IO (Lean.Option Bool)

full_name: Lean.trace.profiler.output.pp
code: register_builtin_option trace.profiler.output.pp : Bool := {
  defValue := false
  group    := "profiler"
  descr    :=
    "if false, limit text in exported trace nodes to trace class name and `TraceData.tag`, if any

This is useful when we are interested in the time taken by specific subsystems instead of specific \
invocations, which is the common case."
}
goal: Lean.Option Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Util.Trace.0.Lean.withStartStop
code: @[inline] private def withStartStop [Monad m] [MonadLiftT BaseIO m] (opts : Options) (act : m α) :
    m (α × Float × Float) 
goal: m (α × Float × Float)

full_name: Lean.trace.profiler.threshold.unitAdjusted
code: @[inline] def trace.profiler.threshold.unitAdjusted (o : Options) : Float 
goal: Float

full_name: Lean.MonadAlwaysExcept.except
code: /--
`MonadExcept` variant that is expected to catch all exceptions of the given type in case the
standard instance doesn't.

In most circumstances, we want to let runtime exceptions during term elaboration bubble up to the
command elaborator (see `Core.tryCatch`). However, in a few cases like building the trace tree, we
really need to handle (and then re-throw) every exception lest we end up with a broken tree.
-/
class MonadAlwaysExcept (ε : outParam (Type u)) (m : Type u → Type v) where
  except : MonadExceptOf ε m
goal: MonadExceptOf ε m

full_name: Lean.MonadAlwaysExcept
code: /--
`MonadExcept` variant that is expected to catch all exceptions of the given type in case the
standard instance doesn't.

In most circumstances, we want to let runtime exceptions during term elaboration bubble up to the
command elaborator (see `Core.tryCatch`). However, in a few cases like building the trace tree, we
really need to handle (and then re-throw) every exception lest we end up with a broken tree.
-/
class MonadAlwaysExcept (ε : outParam (Type u)) (m : Type u → Type v) where
  except : MonadExceptOf ε m
goal: Type (max (u + 1) v)

full_name: Lean.instMonadAlwaysExceptEIO
code: instance : MonadAlwaysExcept ε (EIO ε) 
goal: Lean.MonadAlwaysExcept ε (EIO ε)

full_name: Lean.instMonadAlwaysExceptStateT
code: instance [always : MonadAlwaysExcept ε m] : MonadAlwaysExcept ε (StateT σ m) 
goal: Lean.MonadAlwaysExcept ε (StateT σ m)

full_name: Lean.instMonadAlwaysExceptStateRefT'
code: instance [always : MonadAlwaysExcept ε m] : MonadAlwaysExcept ε (StateRefT' ω σ m) 
goal: Lean.MonadAlwaysExcept ε (StateRefT' ω σ m)

full_name: Lean.instMonadAlwaysExceptReaderT
code: instance [always : MonadAlwaysExcept ε m] : MonadAlwaysExcept ε (ReaderT ρ m) 
goal: Lean.MonadAlwaysExcept ε (ReaderT ρ m)

full_name: Lean.instMonadAlwaysExceptMonadCacheT
code: instance [always : MonadAlwaysExcept ε m] [STWorld ω m] [BEq α] [Hashable α] :
    MonadAlwaysExcept ε (MonadCacheT α β m) 
goal: Lean.MonadAlwaysExcept ε (Lean.MonadCacheT α β m)

full_name: Lean.withTraceNode
code: def withTraceNode [always : MonadAlwaysExcept ε m] [MonadLiftT BaseIO m] (cls : Name)
    (msg : Except ε α → m MessageData) (k : m α) (collapsed := true) (tag := "") : m α 
goal: m α

full_name: Lean.withTraceNode'
code: def withTraceNode' [MonadAlwaysExcept Exception m] [MonadLiftT BaseIO m] (cls : Name)
    (k : m (α × MessageData)) (collapsed := true) (tag := "") : m α 
goal: m α

full_name: Lean.registerTraceClass
code: /--
Registers a trace class.

By default, trace classes are not inherited;
that is, `set_option trace.foo true` does not imply `set_option trace.foo.bar true`.
Calling ``registerTraceClass `foo.bar (inherited := true)`` enables this inheritance
on an opt-in basis.
-/
def registerTraceClass (traceClassName : Name) (inherited := false) (ref : Name := by exact decl_name%) : IO Unit 
goal: IO Unit

full_name: Lean.«doElemTrace[_]__»
code: macro "trace[" id:ident "]" s:(interpolatedStr(term) <|> term) : doElem => do
  let msg ← if s.raw.getKind == interpolatedStrKind then `(m! $(⟨s⟩)) else `(($(⟨s⟩) : MessageData))
  `(doElem| do
    let cls := $(quote id.getId.eraseMacroScopes)
    if (← Lean.isTracingEnabledFor cls) then
      Lean.addTrace cls $msg)
goal: Lean.ParserDescr

full_name: Lean.«_aux_.lake_packages_lean4_src_lean_Lean_Util_Trace___macroRules_Lean_doElemTrace[_]___1»
code: macro "trace[" id:ident "]" s:(interpolatedStr(term) <|> term) : doElem => do
  let msg ← if s.raw.getKind == interpolatedStrKind then `(m! $(⟨s⟩)) else `(($(⟨s⟩) : MessageData))
  `(doElem| do
    let cls := $(quote id.getId.eraseMacroScopes)
    if (← Lean.isTracingEnabledFor cls) then
      Lean.addTrace cls $msg)
goal: Lean.Macro

full_name: Lean.bombEmoji
code: def bombEmoji 
goal: String

full_name: Lean.checkEmoji
code: def checkEmoji 
goal: String

full_name: Lean.crossEmoji
code: def crossEmoji 
goal: String

full_name: Lean.exceptBoolEmoji
code: def exceptBoolEmoji : Except ε Bool → String
  
goal: Except ε Bool → String

full_name: Lean.exceptOptionEmoji
code: def exceptOptionEmoji : Except ε (Option α) → String
  
goal: Except ε (Option α) → String

full_name: Lean.exceptEmoji
code: /-- Visualize an `Except` using a checkmark or a cross. -/
def exceptEmoji : Except ε α → String
  
goal: Except ε α → String

full_name: Lean.ExceptToEmoji.toEmoji
code: class ExceptToEmoji (ε α : Type) where
  toEmoji : Except ε α → String
goal: Except ε α → String

full_name: Lean.ExceptToEmoji
code: class ExceptToEmoji (ε α : Type) where
  toEmoji : Except ε α → String
goal: Type

full_name: Lean.instExceptToEmojiBool
code: instance : ExceptToEmoji ε Bool 
goal: Lean.ExceptToEmoji ε Bool

full_name: Lean.instExceptToEmojiOption
code: instance : ExceptToEmoji ε (Option α) 
goal: Lean.ExceptToEmoji ε (Option α)

full_name: Lean.withTraceNodeBefore
code: /--
Similar to `withTraceNode`, but msg is constructed **before** executing `k`.
This is important when debugging methods such as `isDefEq`, and we want to generate the message
before `k` updates the metavariable assignment. The class `ExceptToEmoji` is used to convert
the result produced by `k` into an emoji (e.g., `💥`, `✅`, `❌`).

TODO: find better name for this function.
-/
def withTraceNodeBefore [MonadRef m] [AddMessageContext m] [MonadOptions m]
    [always : MonadAlwaysExcept ε m] [MonadLiftT BaseIO m] [ExceptToEmoji ε α] (cls : Name)
    (msg : m MessageData) (k : m α) (collapsed := true) (tag := "") : m α 
goal: m α