Anything can be colorized if we ignore the annotations.
Equations
- instColorized_common = { colorize := fun (x : Colorized.Section) (x_1 : Colorized.Color) => id, style := fun (x : Colorized.Style) => id }
- isError : Bool
- posOf : ε → SourceSpan
- msgOf : ε → α
- hintsOf : ε → List α
- name : ε → String
The
-W<name>/-Wno-<name>name this diagnostic is filtered under. Only meaningful for warnings — an error is never suppressed by-W, so its instance leaves this at the default. - code : ε → DiagnosticCode
This diagnostic's stable code (
Common/Diagnostics/Registry.lean), printed aserror[E0042]:and taken as the identity a regression fixture orfugue explainnames. Deliberately without a default: an instance must map every constructor to an entry, so adding a diagnostic without registering it fails to compile.
Instances
A pass with no warnings uses MonadDiagnostic Empty ε m. Lets List Empty still satisfy a
generic [CompilerDiagnostic α String] requirement; every field is Empty.elim since no Empty
value ever exists to apply it to.
Equations
- instCompilerDiagnosticEmptyString = { isError := true, posOf := Empty.elim, msgOf := Empty.elim, code := Empty.elim }
Colorized.color, but a no-op when enabled is false (-fno-color). Not private:
Fugue.lean reuses it for its Built/Replayed progress lines too.
Equations
- colorizeIf enabled c x = if enabled = true then Colorized.Colorized.color c x else x
Instances For
Colorized.style, but a no-op when enabled is false (-fno-color). Not private:
Fugue.lean reuses it too, for its Built/Replayed/Failed progress lines.
Instances For
Renders one diagnostic: an error[E0042]:-style header, the message and its hints, and the
offending source line with the span underlined. colored := false (driven by -fno-color) disables
ANSI styling.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The effects a diagnostics-producing pass needs: an always-growing List α of non-fatal
warnings (MonadWriter), plus MonadExceptOf's throw/catch for a fatal β. The point isn't the
two constraints alone but their interaction, only actually guaranteed by DiagT below: the
accumulated List α survives a throw, unlike the ordinary WriterT (List α) (ExceptT β ·)
order, where a throw short-circuits before the writer's log is ever paired with anything.
Instances
The one concrete MonadDiagnostic α β instance that keeps the promise above: Except β γ
lives inside the pair as ordinary data, rather than as a monadic short-circuit wrapping the pair
from outside — so a throw is just pure ([], .error e), and every warning already tell'd is
already in that [], nothing lost. Also why listen/pass stay lossless, unlike the generic
ExceptT ε N composition, where listen's N (α × ω) shape has nowhere to put ω once α
disappears on a throw.
Instances For
Unwrap a DiagT action down to the underlying m, always pairing every warning tell'd
against it with the final Except-wrapped result — regardless of which branch that result took.
The one place the main driver needs to reach into, to flush a pass's warnings whether or not that
pass ultimately threw.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Lets FlagsEnv/ResolutionStack reach through whatever DiagT layer compileModule runs
at — lifts straight from the base m, same shape as the MonadLift instance above.
Companion to the MonadReaderOf lift above — ResolutionStack's push-on-recurse,
pop-on-return pattern (withReader (mod.name :: ·)) needs to reach through DiagT too.
Equations
- DiagT.instMonadWithReaderOf = { withReader := fun {α_1 : Type (max (max ?u.4 ?u.3) ?u.2)} (f : ρ → ρ) (x : DiagT α β m α_1) => DiagT.mk (withReader f x.run) }
Lifts m's own state through DiagT, so any [MonadStateOf _ m]-generic instance picks it
up automatically without a dedicated DiagT instance.
Equations
- One or more equations did not get rendered due to their size.
Absorbs a self-contained sub-computation's diagnostics into the caller's ambient
MonadDiagnostic α' β' m: tells f-mapped warnings, then throws g e on .error, or returns
the value on .ok. n is x's own base monad (Id for a pure runner, IO-flavored for a nested
recursive call), lifted into m via MonadLiftT so nothing about x's concrete stack leaks into
the caller. Lets a caller let-bind straight through a sub-pass's result without unwrapping its
DiagT/Except by hand.
Equations
- One or more equations did not get rendered due to their size.