| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rzk.Diagnostic
Description
Structured diagnostics for rzk: type errors and holes as data (severity,
a stable code, a source location, and a message) rather than a single
pre-formatted string. The core library produces these; the LSP maps them to
LSP diagnostics, and the CLI can emit them as JSON (rzk typecheck --json).
Locations give the source node's line and column when available, otherwise the nearest enclosing position retained by the checker.
Synopsis
- data Severity
- data Diagnostic = Diagnostic {}
- data HoleData = HoleData {}
- data HoleDataEntry = HoleDataEntry {}
- data HoleDataTope = HoleDataTope {}
- data HoleModalData = HoleModalData {}
- locationToJSON :: LocationInfo -> Value
- typeErrorTag :: forall (n :: S). TypeError n -> String
- typeErrorTagInScopedContext :: TypeErrorInScopedContext -> String
- locationOfTypeError :: TypeErrorInScopedContext -> Maybe LocationInfo
- diagnoseTypeError :: OutputDirection -> TypeErrorInScopedContext -> Diagnostic
- diagnoseCheckWarning :: CheckWarning -> Diagnostic
- ppCheckWarning :: CheckWarning -> String
- checkWarningTag :: CheckWarning -> String
- diagnoseHole :: HoleInfo -> Diagnostic
- holeData :: HoleInfo -> HoleData
- ppHoleInfo :: HoleInfo -> String
- ppLocationInfo :: LocationInfo -> String
Documentation
Diagnostic severity, mirroring the usual LSP levels.
Constructors
| SeverityError | |
| SeverityWarning | |
| SeverityInformation | |
| SeverityHint |
data Diagnostic Source #
A structured diagnostic. Independent of any editor protocol: the LSP maps
it to its own Diagnostic, and the CLI serialises it as JSON.
JSON wire format (rzk typecheck --json)
This is a stable format that downstream tools (e.g. richer LSP hovers) pin to. Each diagnostic is an object:
{ "severity": "error" | "warning" | "information" | "hint"
, "code": <string> -- "hole", or a TypeError tag (e.g. "TypeErrorUnify")
, "location": { "file": <string|null>, "line": <int|null>, "column": <int|null> } | null
, "message": <string> -- human-facing prose (the CLI/LSP display text)
, "hole": <HoleData> | null -- present only for hole diagnostics (see 'HoleData')
}The message field is kept for back-compat (the LSP and the CLI human mode
use it). Structured consumers should read the hole object instead of
parsing message. For non-hole diagnostics hole is null.
Constructors
| Diagnostic | |
Fields
| |
Instances
| ToJSON Diagnostic Source # | |
Defined in Rzk.Diagnostic Methods toJSON :: Diagnostic -> Value # toEncoding :: Diagnostic -> Encoding # toJSONList :: [Diagnostic] -> Value # toEncodingList :: [Diagnostic] -> Encoding # omitField :: Diagnostic -> Bool # | |
| Show Diagnostic Source # | |
Defined in Rzk.Diagnostic Methods showsPrec :: Int -> Diagnostic -> ShowS # show :: Diagnostic -> String # showList :: [Diagnostic] -> ShowS # | |
| Eq Diagnostic Source # | |
Defined in Rzk.Diagnostic | |
The structured payload of a hole diagnostic: the goal and local context as
already-rendered display strings (the same strings the LSP/CLI show, i.e.
show = printTree on the underlying terms). Consumers render hole panels
from these fields directly, without parsing the human-facing message.
JSON wire format
{ "name": <string|null> -- the ?name, if the hole was named
, "goal": <string> -- the expected type (the goal)
, "shape": { "binder": <string>, "tope": <string> } | null
, "termVars": [ <entry>, ... ]
, "cubeVars": [ <entry>, ... ]
, "topes": [ <string>, ... ] -- tope assumptions in force (excludes ⊤)
, "topeInfo": [ { "tope": <string>, <modal> }, ... ] -- all tope assumptions
}where an entry is { "name": string, "type": string, modal } and
modal is "modality": string, "locks": string, "accessible": bool:
the declared modality, the locks accumulated since, and whether the entry
can be used at the hole. An inaccessible tope is not in force, so it appears
in topeInfo but not in topes.
Notes for consumers:
shapeis non-null only for a shape-restricted argument goal, where the goal reads(binder : goal | tope). For an extension type the boundary is already part ofgoal(a restricted typeA [ … ↦ … ]), andshapeisnull— read the boundary out ofgoal.cubeVarsnames can be patterns like"(t, s)"(pair-pattern binders); they are display strings, not single identifiers.
Constructors
| HoleData | |
Fields
| |
data HoleDataEntry Source #
Constructors
| HoleDataEntry | |
Fields | |
Instances
| Show HoleDataEntry Source # | |
Defined in Rzk.Diagnostic Methods showsPrec :: Int -> HoleDataEntry -> ShowS # show :: HoleDataEntry -> String # showList :: [HoleDataEntry] -> ShowS # | |
| Eq HoleDataEntry Source # | |
Defined in Rzk.Diagnostic Methods (==) :: HoleDataEntry -> HoleDataEntry -> Bool # (/=) :: HoleDataEntry -> HoleDataEntry -> Bool # | |
data HoleDataTope Source #
Constructors
| HoleDataTope | |
Fields | |
Instances
| Show HoleDataTope Source # | |
Defined in Rzk.Diagnostic Methods showsPrec :: Int -> HoleDataTope -> ShowS # show :: HoleDataTope -> String # showList :: [HoleDataTope] -> ShowS # | |
| Eq HoleDataTope Source # | |
Defined in Rzk.Diagnostic | |
data HoleModalData Source #
Constructors
| HoleModalData | |
Fields | |
Instances
| Show HoleModalData Source # | |
Defined in Rzk.Diagnostic Methods showsPrec :: Int -> HoleModalData -> ShowS # show :: HoleModalData -> String # showList :: [HoleModalData] -> ShowS # | |
| Eq HoleModalData Source # | |
Defined in Rzk.Diagnostic Methods (==) :: HoleModalData -> HoleModalData -> Bool # (/=) :: HoleModalData -> HoleModalData -> Bool # | |
locationToJSON :: LocationInfo -> Value Source #
Encode a location as JSON. A plain helper rather than a ToJSON instance,
to avoid an orphan instance (LocationInfo is defined in Rzk.TypeCheck).
typeErrorTag :: forall (n :: S). TypeError n -> String Source #
A stable tag for a type error, used as its diagnostic code. Independent of the variable type, so it survives the scoped-error unfolding.
typeErrorTagInScopedContext :: TypeErrorInScopedContext -> String Source #
The tag of a type error.
An error carries the context it was raised in, so there are no binder layers to peel: the old representation nested the error one Inc deeper at every binder.
locationOfTypeError :: TypeErrorInScopedContext -> Maybe LocationInfo Source #
The source location of a type error (the enclosing command's line).
diagnoseTypeError :: OutputDirection -> TypeErrorInScopedContext -> Diagnostic Source #
A structured diagnostic for a type error. The message is the usual
formatted error text; severity is always SeverityError.
diagnoseCheckWarning :: CheckWarning -> Diagnostic Source #
A checker warning as a diagnostic: warning severity, with the warning's
constructor name as the stable code (like diagnoseTypeError does for
errors).
ppCheckWarning :: CheckWarning -> String Source #
A checker warning as a human-readable line (the CLI).
checkWarningTag :: CheckWarning -> String Source #
The stable tag of a warning (its diagnostic code), used to match
warnings in fixtures; sharing the definition keeps the two from
drifting apart.
diagnoseHole :: HoleInfo -> Diagnostic Source #
A structured diagnostic for a hole, carrying the hole's goal and local
context. A hole is an unfilled obligation, so it is a SeverityWarning —
mirroring Agda's yellow "unsolved" highlight, and visible in the editor's
problems panel (unlike SeverityHint, which editors render almost
invisibly). Finished work still rejects holes outright: the strict default
of rzk typecheck reports them as errors (cf. Agda's --safe).
holeData :: HoleInfo -> HoleData Source #
The structured payload of a hole: its goal and local context rendered to
display strings (the same rendering ppHoleInfo uses, but kept as separate
fields rather than concatenated into prose). See HoleData.
ppHoleInfo :: HoleInfo -> String Source #
Render a hole's goal and local context (the structured query) for display, separating term variables, cube variables, and tope assumptions.
ppLocationInfo :: LocationInfo -> String Source #