rzk-0.11.4: 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 structured checker diagnostic. Safe error mode rejects fragment violations.

Constructors

LargeInductiveTypeWarning 

Fields

MetaPrefixWarning 

Fields

RSTTScopeWarning RSTTExtension String (Maybe LocationInfo) 
RSTTHoleWarning (Maybe LocationInfo) 
RSTTIncompleteWarning String (Maybe LocationInfo) 
OverhangWarning 

Fields

TopeFamilyDomainWarning 

Fields

FreeStandingRestrictionWarning 

Fields

MetaBinderWarning 

Fields

Instances

Instances details
Show CheckWarning Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

Eq CheckWarning Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

data RSTTExtension Source #

Diagnostic categories for constructs outside the RSTT fragment.

Instances

Instances details
Show RSTTExtension Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

Eq RSTTExtension Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

data FragmentUse Source #

What assumes a free-standing restriction (see Rzk.TypeCheck.Fragment.RSTT), which conservativity allows to be concluded but not assumed.

Constructors

UseBinder

the type of a binder (λ, Π, Σ, or a declaration's parameter)

UseMotive

the motive of an eliminator

UseData

inside a type passed as data, at a meta-typed argument or component

UseIdentity

the type of an identity type, whose endpoints it types

UseConcluded

a concluded type, off the spine of codomains (a Σ component, say)

Instances

Instances details
Show FragmentUse Source # 
Instance details

Defined in Rzk.TypeCheck.Monad

Eq FragmentUse 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.

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 #

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

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

localWarnMetaBinder :: 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). Distinct n => HoleInfo -> TypeCheck n () Source #

Warnings

recordCheckWarning :: forall (n :: S). Distinct n => CheckWarning -> TypeCheck n () Source #

Record a warning once, rejecting fragment violations in safe error mode.

rsttViolation :: CheckWarning -> Maybe String Source #

Describe a fragment violation; return Nothing for unrelated warnings.

reportIncompleteRSTTCheck :: forall (n :: S). Distinct n => String -> TypeErrorInScopedContext -> TypeCheck n () Source #

Report an unfinished fragment check without masking a safe-mode error.

Locations

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