| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rzk.TypeCheck.Monad
Description
The checker's monad.
TypeCheck n is the old TypeCheck var with the scope index in place of the
variable type. The error channel, though, is not indexed: an error carries
the context it was raised in (see Rzk.TypeCheck.Error). That is what makes
inContext a one-liner — running a judgement in an inner scope is just running
it under a different reader, with nothing to re-index on the way out. The old
closeScope had to wrap the error one binder deeper and re-emit the holes.
Synopsis
- data HoleEntry = HoleEntry {}
- data HoleInfo = HoleInfo {
- holeName :: Maybe VarIdent
- holeGoal :: Rendered
- holeGoalShape :: Maybe (VarIdent, Rendered)
- holeTermVars :: [HoleEntry]
- holeCubeVars :: [HoleEntry]
- holeTopes :: [Rendered]
- holeCandidates :: [Rendered]
- holeIntroductions :: [Rendered]
- holeDiagram :: Maybe String
- holeLocation :: Maybe LocationInfo
- data CheckWarning
- warningLocation :: CheckWarning -> Maybe LocationInfo
- data MetaPrefixRule
- data CheckLog = CheckLog {
- logHolesRev :: [HoleInfo]
- logWarningsRev :: [CheckWarning]
- emptyCheckLog :: CheckLog
- checkLog :: CheckLog -> ([HoleInfo], [CheckWarning])
- type TypeCheck (n :: S) = ReaderT (Context n) (ExceptT TypeErrorInScopedContext (State CheckLog))
- runTypeCheckWith :: forall (n :: S) a. Context n -> TypeCheck n a -> (Either TypeErrorInScopedContext a, ([HoleInfo], [CheckWarning]))
- runTypeCheck :: TypeCheck 'VoidS a -> Either TypeErrorInScopedContext a
- runTypeCheckIn :: forall (n :: S) a. Context n -> TypeCheck n a -> Either TypeErrorInScopedContext a
- inContext :: forall (l :: S) a (n :: S). Context l -> TypeCheck l a -> TypeCheck n a
- issueTypeError :: forall (n :: S) a. Distinct n => TypeError n -> TypeCheck n a
- issueWarning :: forall (n :: S). String -> TypeCheck n ()
- trace' :: Verbosity -> Verbosity -> String -> a -> a
- traceTypeCheck :: forall (n :: S) a. Verbosity -> String -> TypeCheck n a -> TypeCheck n a
- localVerbosity :: forall (n :: S) a. Verbosity -> TypeCheck n a -> TypeCheck n a
- localRenderBackend :: forall (n :: S) a. Maybe RenderBackend -> TypeCheck n a -> TypeCheck n a
- localHideTerm :: forall (n :: S) a. Bool -> TypeCheck n a -> TypeCheck n a
- localWarnOverhang :: forall (n :: S) a. Bool -> TypeCheck n a -> TypeCheck n a
- localMetaPrefixSensitivity :: forall (n :: S) a. MetaPrefixSensitivity -> TypeCheck n a -> TypeCheck n a
- hidingTerm :: forall (n :: S) a. TypeCheck n a -> TypeCheck n a
- switchVariance :: forall (n :: S) a. TypeCheck n a -> TypeCheck n a
- setVariance :: forall (n :: S) a. Covariance -> TypeCheck n a -> TypeCheck n a
- maxActionStackDepth :: Int
- performing :: forall (n :: S) a. Distinct n => Action n -> TypeCheck n a -> TypeCheck n a
- narrowLocation :: forall (n :: S). Action n -> Maybe LocationInfo -> Maybe LocationInfo
- modifyLog :: forall (n :: S). (CheckLog -> CheckLog) -> TypeCheck n ()
- suppressing :: forall (n :: S) a. TypeCheck n a -> TypeCheck n a
- recordHoleInfo :: forall (n :: S). HoleInfo -> TypeCheck n ()
- recordCheckWarning :: forall (n :: S). CheckWarning -> TypeCheck n ()
- withLocation :: forall (n :: S) a. LocationInfo -> TypeCheck n a -> TypeCheck n a
Documentation
A binding shown in a hole's local context: the display name and its type, already rendered.
Constructors
| HoleEntry | |
Fields | |
The structured goal and context at a hole, recorded in lenient mode (see
allowHoles). Everything is rendered to user-facing names at record time, so
HoleInfo is independent of the scope it came from. Local hypotheses are split
into ordinary term variables and cube variables (the cube/tope layer is
specific to Rzk); the global environment is deliberately excluded — it belongs
in a searchable inventory, not the goal panel.
Constructors
| HoleInfo | |
Fields
| |
Instances
data CheckWarning Source #
A non-fatal finding of the checker, recorded on the writer channel
beside the holes and carried out of a run in Checked. Structured, so
the CLI, the LSP, and (later) safe mode each decide how to present or
escalate it.
Constructors
| LargeInductiveTypeWarning | |
Fields
| |
| MetaPrefixWarning | |
Fields
| |
Instances
| Show CheckWarning Source # | |
Defined in Rzk.TypeCheck.Monad Methods showsPrec :: Int -> CheckWarning -> ShowS # show :: CheckWarning -> String # showList :: [CheckWarning] -> ShowS # | |
| Eq CheckWarning Source # | |
Defined in Rzk.TypeCheck.Monad | |
warningLocation :: CheckWarning -> Maybe LocationInfo Source #
Where a warning points, for per-file attribution.
data MetaPrefixRule Source #
Which candidate rule of the meta-parameter layer check flags a
MetaPrefixWarning (see Rzk.TypeCheck.MetaPrefix): the structural
rule, or only its stricter variant. Both are emitted so the two
candidate defaults can be measured on a corpus side by side.
Constructors
| MetaPrefixBoth | |
| MetaPrefixStrictOnly |
Instances
| Show MetaPrefixRule Source # | |
Defined in Rzk.TypeCheck.Monad Methods showsPrec :: Int -> MetaPrefixRule -> ShowS # show :: MetaPrefixRule -> String # showList :: [MetaPrefixRule] -> ShowS # | |
| Eq MetaPrefixRule Source # | |
Defined in Rzk.TypeCheck.Monad Methods (==) :: MetaPrefixRule -> MetaPrefixRule -> Bool # (/=) :: MetaPrefixRule -> MetaPrefixRule -> Bool # | |
What a run records besides its result: the holes it found and the non-fatal
findings it made. Both accumulate in reverse and are turned around by
checkLog when the run ends.
Constructors
| CheckLog | |
Fields
| |
checkLog :: CheckLog -> ([HoleInfo], [CheckWarning]) Source #
What a run recorded, in the order it was recorded.
type TypeCheck (n :: S) = ReaderT (Context n) (ExceptT TypeErrorInScopedContext (State CheckLog)) Source #
The record of a run is kept in the state, beneath the error channel, rather than on a writer channel above it.
The two differ exactly where a caught error is concerned: a writer discards
what the failing action wrote, and the state keeps it. That is what the
checker wants. A command that fails still reports the holes the user wrote in
it, and checking goes on to the next command with those holes in hand (see
withCommand in Rzk.TypeCheck.Decl). A probe that wants the older
behaviour asks for it, with suppressing.
runTypeCheckWith :: forall (n :: S) a. Context n -> TypeCheck n a -> (Either TypeErrorInScopedContext a, ([HoleInfo], [CheckWarning])) Source #
Run a judgement in a given context, keeping what it recorded.
runTypeCheck :: TypeCheck 'VoidS a -> Either TypeErrorInScopedContext a Source #
Run a judgement in the empty context, discarding the holes it records.
runTypeCheckIn :: forall (n :: S) a. Context n -> TypeCheck n a -> Either TypeErrorInScopedContext a Source #
Run a judgement in a given context, discarding the holes it records.
inContext :: forall (l :: S) a (n :: S). Context l -> TypeCheck l a -> TypeCheck n a Source #
Run a judgement in another scope's context.
The error channel and the hole channel are shared and carry no scope index, so
there is nothing to translate: this is runReaderT with the inner scope's
context, lifted back. Holes recorded inside land in the same state, and an
error thrown inside already carries its own context.
Errors
issueTypeError :: forall (n :: S) a. Distinct n => TypeError n -> TypeCheck n a Source #
Raise a type error, capturing the context it happened in.
Tracing
localRenderBackend :: forall (n :: S) a. Maybe RenderBackend -> TypeCheck n a -> TypeCheck n a Source #
localMetaPrefixSensitivity :: forall (n :: S) a. MetaPrefixSensitivity -> TypeCheck n a -> TypeCheck n a Source #
hidingTerm :: forall (n :: S) a. TypeCheck n a -> TypeCheck n a Source #
Render the enclosed action with the proof term hidden.
Variance
setVariance :: forall (n :: S) a. Covariance -> TypeCheck n a -> TypeCheck n a Source #
The judgement stack
maxActionStackDepth :: Int Source #
The depth of nested judgements at which type checking gives up. Well-typed
input stays far below it; the cap catches a non-terminating search.
FIXME: expose as a parameter (--max-depth and rzk.yaml).
narrowLocation :: forall (n :: S). Action n -> Maybe LocationInfo -> Maybe LocationInfo Source #
Point the location at the sub-term an action is about.
The checker descends through performing, so the location narrows as it
goes and an error is reported where the sub-term that caused it was written,
rather than at the declaration it is in (issue #81). A judgement about a term
the checker built itself carries no position, and leaves the location as it
found it: that is the innermost enclosing term the user did write.
What a run records
suppressing :: forall (n :: S) a. TypeCheck n a -> TypeCheck n a Source #
Run a probe for its answer alone, discarding whatever it records.
A hole's inventory is built by trying candidate moves and seeing which fit,
and each trial checks terms of its own; their holes and warnings are not the
user's and must not reach the report. This is what the writer channel's
censor did before the record moved into the state: the state survives an
error, so it is put back on that path too.
Holes
Warnings
recordCheckWarning :: forall (n :: S). CheckWarning -> TypeCheck n () Source #
Locations
withLocation :: forall (n :: S) a. LocationInfo -> TypeCheck n a -> TypeCheck n a Source #