rzk-0.11.3: An experimental proof assistant for synthetic ∞-categories
Safe HaskellNone
LanguageHaskell2010

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

Documentation

data HoleEntry Source #

A binding shown in a hole's local context: the display name and its type, already rendered.

Instances

Instances details
Show HoleEntry Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

Eq HoleEntry Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

data HoleInfo Source #

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

Instances details
Show HoleInfo Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

Eq HoleInfo Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

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

Instances details
Show CheckWarning Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

Eq CheckWarning Source # 
Instance details

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.

Instances

Instances details
Show MetaPrefixRule Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

Eq MetaPrefixRule Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

data CheckLog Source #

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 

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.

issueWarning :: forall (n :: S). String -> TypeCheck n () Source #

Tracing

traceTypeCheck :: forall (n :: S) a. Verbosity -> String -> TypeCheck n a -> TypeCheck n a Source #

localVerbosity :: forall (n :: S) a. Verbosity -> TypeCheck n a -> TypeCheck n a Source #

localHideTerm :: forall (n :: S) a. Bool -> TypeCheck n a -> TypeCheck n a Source #

localWarnOverhang :: forall (n :: S) a. Bool -> 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

switchVariance :: forall (n :: S) a. TypeCheck n a -> TypeCheck n a Source #

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).

performing :: forall (n :: S) a. Distinct n => Action n -> TypeCheck n a -> TypeCheck n a Source #

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

modifyLog :: forall (n :: S). (CheckLog -> CheckLog) -> TypeCheck n () Source #

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

recordHoleInfo :: forall (n :: S). HoleInfo -> TypeCheck n () Source #

Warnings

Locations

withLocation :: forall (n :: S) a. LocationInfo -> TypeCheck n a -> TypeCheck n a Source #