Check that an expression is a type.
ModuleAgda-2.7.0.1Haskell2010
Agda.TypeChecking.Rules.Term
- 1 type
- 57 values
- PackageAgda-2.7.0.1
- Exports58
- LanguageHaskell2010
- LicenceMIT
- SourceTerm.hs
Types
6 declarationsCheck that an expression is a type.
* If c == CmpEq, the given sort must be the minimal sort.
* If c == CmpLeq, the given sort may be any bigger sort.
Check that an expression is a type and infer its (minimal) sort.
Ensure that a (freshly created) function type does not inhabit SizeUniv.
Precondition: When noFunctionsIntoSize t tBlame is called,
we are in the context of tBlame in order to print it correctly.
Not being in context of t should not matter, as we are only
checking whether its sort reduces to SizeUniv.
Currently UNUSED since SizeUniv is turned off (as of 2016).
Check that an expression is a type which is equal to a given type.
Telescopes
11 declarationscheckGeneralizeTelescope :: Maybe ModuleNameThe module the telescope belongs to (if any).
-> GeneralizeTelescopeTelescope to check and add to the context for the continuation.
-> ([Maybe Name] -> Telescope -> TCM a)Continuation living in the extended context.
-> TCM a
Type check a (module) telescope. Binds the variables defined by the telescope.
Type check the telescope of a dependent function type. Binds the resurrected variables defined by the telescope. The returned telescope is unmodified (not resurrected).
Flag to control resurrection on domains.
Constructors
LamNotPiWe are checking a module telescope. We pass into the type world to check the domain type. This resurrects the whole context.
PiNotLamWe are checking a telescope in a Pi-type. We stay in the term world, but add resurrected domains to the context to check the remaining domains and codomain of the Pi-type.
Type check a telescope. Binds the variables defined by the telescope.
Check the domain of a function type.
Used in checkTypedBindings and to typecheck A.Fun cases.
Check a typed binding and extends the context with the bound variables. The telescope passed to the continuation is valid in the original context.
Parametrized by a flag whether we check a typed lambda or a Pi. This flag is needed for irrelevance.
After a typed binding has been checked, add the patterns it binds
Check a tactic attribute. Should have type Term → TC ⊤.
Lambda abstractions
14 declarationsType check a lambda expression. "checkLambda bs e ty" means ( bs -> e) : ty
checkLambda' Check that modality info in lambda is compatible with modality coming from the function type. If lambda has no user-given modality, copy that of function type.
Check that irrelevance info in lambda is compatible with irrelevance coming from the function type. If lambda has no user-given relevance, copy that of function type.
Check that quantity info in lambda is compatible with quantity coming from the function type. If lambda has no user-given quantity, copy that of function type.
Check that cohesion info in lambda is compatible with cohesion coming from the function type. If lambda has no user-given cohesion, copy that of function type.
Checking a lambda whose domain type has already been checked.
insertHiddenLambdas :: HidingExpected hiding.
-> TypeExpected to be a function type.
-> (Blocker -> Type -> TCM Term)Continuation on blocked type.
-> (Type -> TCM Term)Continuation when expected hiding found. The continuation may assume that the
Typeis of the form(El _ (Pi _ _)).-> TCM TermTerm with hidden lambda inserted.
Insert hidden lambda until the hiding info of the domain type matches the expected hiding info. Throws WrongHidingInLambda
checkAbsurdLambda i h e t checks absurd lambda against type t.
Precondition: e = AbsurdLam i h
checkExtendedLambda i di erased qname cs e t check pattern matching lambda.
Precondition: e = ExtendedLam i di erased qname cs
Run a computation.
If successful, that's it, we are done.
If
NotADatatype aorCannotEliminateWithPattern p ais thrown and typeais blocked on some metax, reset any changes to the state and pass (the error and)xto the handler.If
SplitError (UnificationStuck c tel us vs _)is thrown and the unification problemus =?= vs : telis blocked on some metaxpassxto the handler.If another error was thrown or the type
ais not blocked, reraise the error.
Note that the returned meta might only exists in the state where the error was thrown, thus, be an invalid MetaId in the current state.
Records
3 declarationsexpandModuleAssigns Picks up record field assignments from modules that export a definition that has the same name as the missing field.
checkRecordExpression :: ComparisonHow do we related the inferred type of the record expression to the expected type? Subtype or equal type?
-> RecordAssignsmfs: modules and field assignments.-> ExprMust be
A.Rec _ mfs.-> TypeExpected type of record expression.
-> TCM TermRecord value in internal syntax.
checkRecordExpression fs e t checks record construction against type t.
Precondition e = Rec _ fs.
checkRecordUpdate checkRecordUpdate cmp ei recexpr fs e tPreconditions: e = RecUpdate ei recexpr fs and t is reduced.
Literal
1 declarationTerms
3 declarationsRemove top layers of scope info of expression and set the scope accordingly in the TCState.
Type check an expression.
Reflection
3 declarationsUnquote a TCM computation in a given hole.
Run a tactic `tac : Term → TC ⊤` in a hole (second argument) of the type given by the third argument. Runs the continuation if successful.
Meta variables
15 declarationscheckQuestionMark :: (Comparison -> Type -> TCM (MetaId, Term))-> Comparison-> TypeNot reduced!
-> MetaInfo-> InteractionId-> TCM Term
Check an interaction point without arguments.
Check an underscore without arguments.
Type check a meta variable.
Infer the type of a meta variable. If it is a new one, we create a new meta for its type.
Type check a meta variable. If its type is not given, we return its type, or a fresh one, if it is a new meta. If its type is given, we check that the meta has this type, and we return the same type.
Turn a domain-free binding (e.g. lambda) into a domain-full one, by inserting an underscore for the missing type.
checkKnownArguments Check arguments whose value we already know.
This function can be used to check user-supplied parameters we have already computed by inference.
Precondition: The type t of the head has enough domains.
checkKnownArgument Check an argument whose value we already know.
Check a single argument.
Infer the type of an expression. Implemented by checking against a meta variable. Except for neutrals, for them a polymorphic type is inferred.
Used to check aliases f = e.
Switches off ExpandLast for the checking of top-level application.
Check whether a de Bruijn index is bound by a module telescope.
Infer the type of an expression, and if it is of the form
{tel} -> D vs for some datatype D then insert the hidden
arguments. Otherwise, leave the type polymorphic.