| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rzk.Check.Context
Description
The typing context of the new checker: what every name in scope is, the tope context, the direction of a comparison, the options, and the stack of judgements kept for diagnostics.
Every entry holds values: the type of the name, and for a definition its value, evaluated once. The context is also the evaluation context of free-foil-NBE (the instance is in Rzk.Check.Value), so evaluation reads definitions and topes from the same place the checker does.
Synopsis
- type Value = Value Pattern Sig
- data Variance
- opposite :: Variance -> Variance
- data Verbosity
- data LocationInfo = LocationInfo {}
- atPosition :: RzkPosition -> LocationInfo -> LocationInfo
- data HoleMode
- data Options = Options {}
- defaultOptions :: Options
- data Approximation
- data Unfolding
- data EntryKind
- data Entry (n :: S) = Entry {
- entryType :: Value n
- entryValue :: Maybe (Value n)
- entryModality :: TModality
- entryLocks :: TModality
- entryKind :: EntryKind
- entryName :: Maybe VarIdent
- entryLocation :: Maybe LocationInfo
- entryUses :: [Name n]
- entryTypeCore :: Maybe (Core n)
- entryValueCore :: Maybe (Core n)
- localEntry :: forall (n :: S). TModality -> Maybe VarIdent -> Maybe LocationInfo -> Value n -> Entry n
- data Section (n :: S) = Section {
- sectionName :: Maybe String
- sectionEntries :: [Name n]
- data Action (n :: S)
- = ActionCheck (Raw n) (Value n)
- | ActionInfer (Raw n)
- | ActionConvert (Value n) (Value n)
- | ActionEntails [Tope n] (Tope n)
- | ActionEntailsUnion [Tope n] [Tope n]
- | ActionCheckLetValue (Maybe VarIdent)
- | ActionCloseSection (Maybe String)
- data Diag (n :: S) = Diag {
- diagActions :: [Action n]
- diagDepth :: !Int
- emptyDiag :: forall (n :: S). Diag n
- data Context (n :: S) = Context {
- ctxScope :: Scope n
- ctxEntries :: NameMap n (Entry n)
- ctxNamed :: Map VarIdent (Name n)
- ctxBound :: [Name n]
- ctxTopes :: TopeContext n
- ctxVariance :: Variance
- ctxUnfolding :: Unfolding
- ctxApproximation :: Approximation
- ctxOptions :: Options
- ctxLocation :: Maybe LocationInfo
- ctxSections :: [Section n]
- ctxDiag :: Diag n
- emptyContext :: Context 'VoidS
- lookupEntry :: forall (n :: S). Name n -> Context n -> Entry n
- lookupNamed :: forall (n :: S). VarIdent -> Context n -> Maybe (Name n)
- entriesInScope :: forall (n :: S). Context n -> [(Name n, Entry n)]
- enterPattern :: forall (n :: S) (l :: S). (Distinct n, DExt n l) => Pattern n l -> [Entry l] -> Context n -> Context l
- sinkContextUnchecked :: forall (n :: S) (l :: S). DExt n l => Context n -> Context l
- insertEntry :: forall (n :: S). Name n -> Entry n -> Context n -> Context n
- withVariance :: forall (n :: S). Variance -> Context n -> Context n
Values
type Value = Value Pattern Sig Source #
A value of the core: free-foil-NBE's, over the pattern binder and the signature.
Pieces
The direction of a comparison: whether the expected side is the supertype, the subtype, or neither.
Constructors
| Covariant | |
| Contravariant | |
| Invariant |
Instances
Instances
| Show Verbosity Source # | |
| Eq Verbosity Source # | |
| Ord Verbosity Source # | |
data LocationInfo Source #
Where a diagnostic points: the start of the declaration being checked, narrowed to the sub-term as the checker descends into it.
Constructors
| LocationInfo | |
Fields | |
Instances
| Show LocationInfo Source # | |
Defined in Rzk.Check.Context Methods showsPrec :: Int -> LocationInfo -> ShowS # show :: LocationInfo -> String # showList :: [LocationInfo] -> ShowS # | |
| Eq LocationInfo Source # | |
Defined in Rzk.Check.Context | |
atPosition :: RzkPosition -> LocationInfo -> LocationInfo Source #
Point a location at a position in the same file.
How a user hole is treated.
Constructors
| HolesAreErrors | reject an unsolved hole; the default for finished work and CI |
| HolesDeferred | record the goal and let the hole stand for a term of any type |
| HolesStructural | record the goal, but tolerate a mismatch only at a hole leaf of an otherwise matching structure |
Instances
The options a run or a file sets.
Constructors
| Options | |
Fields
| |
defaultOptions :: Options Source #
The default options.
>>>defaultOptionsOptions {optVerbosity = Normal, optHoles = HolesAreErrors, optHintLemmas = [], optWarnOverhang = False, optWarnTopeFamilyDomain = True, optRender = Nothing}
data Approximation Source #
The state of a conversion check, after the approximate conversion
checking of Kovács's smalltt. A check starts ApproxRigid. Two glued
values of one defined name compare their folded sides ApproxFlex, with
no unfolding, and if these differ their unfolded sides ApproxFull.
Constructors
| ApproxRigid | unfold distinct definitions; equal ones may first compare folded |
| ApproxFlex | compare folded sides of one definition, without unfolding |
| ApproxFull | allow a full unfolded comparison after the folded attempt |
Instances
| Show Approximation Source # | |
Defined in Rzk.Check.Context Methods showsPrec :: Int -> Approximation -> ShowS # show :: Approximation -> String # showList :: [Approximation] -> ShowS # | |
| Eq Approximation Source # | |
Defined in Rzk.Check.Context Methods (==) :: Approximation -> Approximation -> Bool # (/=) :: Approximation -> Approximation -> Bool # | |
Entries
Constructors
| EntryLocal | a local binder, not collected when a section closes |
| EntryAssumption | a section assumption, abstracted away when the section closes |
| EntryTopLevel | a definition or postulate that survives the section |
What is known about a name in scope.
Constructors
| Entry | |
Fields
| |
localEntry :: forall (n :: S). TModality -> Maybe VarIdent -> Maybe LocationInfo -> Value n -> Entry n Source #
The entry of a local name of a type.
data Section (n :: S) Source #
An open section: its name, and the top-level entries made in it, newest first. The module itself is an anonymous section, so that an assumption outside any named section is abstracted at the end of the module.
Constructors
| Section | |
Fields
| |
Diagnostics
The judgement being performed, for the trace and the error report.
Constructors
| ActionCheck (Raw n) (Value n) | check a raw term against a type value |
| ActionInfer (Raw n) | infer the type of a raw term |
| ActionConvert (Value n) (Value n) | compare an expected value with an actual one |
| ActionEntails [Tope n] (Tope n) | check that the listed context topes entail a goal |
| ActionEntailsUnion [Tope n] [Tope n] | check that the listed context topes are covered by a union |
| ActionCheckLetValue (Maybe VarIdent) | check or infer a local definition's value |
| ActionCloseSection (Maybe String) | close a named section, or the anonymous module section |
What a full run keeps for its diagnostics: the stack of judgements.
Constructors
| Diag | |
Fields
| |
The context
data Context (n :: S) Source #
Constructors
| Context | |
Fields
| |
Instances
| Eval Context Pattern Sig | |
Defined in Rzk.Check.Value Methods definition :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n unfolding :: forall (n :: S). Scope n -> Context n -> Value Pattern Sig n -> Value Pattern Sig n -> Value Pattern Sig n glueSpeculation :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n -> Name n -> Value Pattern Sig n -> GlueSpeculation Context n unfoldGlued :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n -> Maybe (Context n) evalSig :: forall (o :: S) (i :: S). (Distinct o, Distinct i) => Scope o -> Context o -> Substitution (Value Pattern Sig) i o -> Sig (ScopedAST Pattern Sig i) (AST Pattern Sig i) -> Value Pattern Sig o etaMatchWith :: forall a (n :: S) c b d. (a -> EtaScoped Context Pattern Sig n -> c) -> (b -> EtaTerm Context Pattern Sig n -> d) -> Sig a b -> Maybe (Sig c d) extendScopedWith :: forall (n :: S) a c d. Distinct n => (a -> Extend Context Pattern Sig n -> c) -> (Value Pattern Sig n -> d) -> Sig a (Value Pattern Sig n) -> Sig c d relateWith :: forall m (n :: S) a a'. (Monoid m, Distinct n) => Scope n -> Context n -> (a -> a' -> Context n -> Extend Context Pattern Sig n -> m) -> (Value Pattern Sig n -> Value Pattern Sig n -> Context n -> m) -> (Value Pattern Sig n -> Value Pattern Sig n -> Context n -> m) -> Sig a (Value Pattern Sig n) -> Sig a' (Value Pattern Sig n) -> Maybe m relateMismatch :: forall (n :: S). (Eval Context Pattern Sig, Distinct n) => Scope n -> Context n -> Value Pattern Sig n -> Value Pattern Sig n -> Bool refineVar :: forall (n :: S). (Eval Context Pattern Sig, Distinct n) => Scope n -> Context n -> Name n -> Value Pattern Sig n refineSig :: forall (n :: S) a. (Eval Context Pattern Sig, Distinct n) => Scope n -> Context n -> Value Pattern Sig n -> Sig a (Value Pattern Sig n) -> Value Pattern Sig n binderValue :: forall (n :: S) (l :: S). (Distinct n, Distinct l) => Scope l -> Context l -> Pattern n l -> Maybe (Value Pattern Sig l) bindValue :: forall (o :: S) (i :: S) (l :: S). Distinct o => Scope o -> Context o -> Substitution (Value Pattern Sig) i o -> Pattern i l -> Value Pattern Sig o -> Maybe (Substitution (Value Pattern Sig) l o) evalBinder :: forall (n :: S) (i :: S) (e :: S -> Type) (l :: S) r. (CoSinkable Pattern, Distinct n, Distinct i, Sinkable e, InjectName e) => Scope n -> Context n -> Substitution (Value Pattern Sig) i n -> Pattern i l -> (forall (n' :: S). DExt n n' => (Substitution e i n -> Substitution e l n') -> Pattern n n' -> Scope n' -> r) -> r | |
| HasDefinitions Context Pattern Sig | A defined name is glued to its value; any other name is a neutral. |
Defined in Rzk.Check.Value Methods contextDefinition :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n contextUnfolding :: forall (n :: S). Scope n -> Context n -> Value Pattern Sig n -> Value Pattern Sig n -> Value Pattern Sig n contextGlueSpeculation :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n -> Name n -> Value Pattern Sig n -> GlueSpeculation Context n contextUnfoldGlued :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n -> Maybe (Context n) | |
emptyContext :: Context 'VoidS Source #
The empty context, with defaultOptions. Conversion starts covariantly,
with definitions unfolded and the rigid approximation strategy.
>>>ctxVariance emptyContextCovariant>>>case ctxUnfolding emptyContext of { Unfolded -> True; Folded -> False }True>>>ctxApproximation emptyContextApproxRigid
lookupEntry :: forall (n :: S). Name n -> Context n -> Entry n Source #
What a name stands for. Total: every name in scope has an entry.
entriesInScope :: forall (n :: S). Context n -> [(Name n, Entry n)] Source #
Every entry in scope, oldest binding first.
enterPattern :: forall (n :: S) (l :: S). (Distinct n, DExt n l) => Pattern n l -> [Entry l] -> Context n -> Context l Source #
Enter the scope of a pattern: extend the scope with its names and record an entry for each, in binding order.
sinkContextUnchecked :: forall (n :: S) (l :: S). DExt n l => Context n -> Context l Source #
Sink a context along a scope extension. Unsound on its own: the scope
and the entries still describe the old scope, so the caller must extend
both, as enterPattern does. Everything else in the context mentions
the scope only through values and names, which sink by coercion.