Agda-2.5.4: A dependently typed functional programming language and proof assistant

Safe HaskellNone
LanguageHaskell2010

Agda.TypeChecking.Rules.Term

Contents

Synopsis

Types

isType :: Expr -> Sort -> TCM Type #

Check that an expression is a type.

isType_ :: Expr -> TCM Type #

Check that an expression is a type without knowing the sort.

noFunctionsIntoSize :: Type -> Type -> TCM () #

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.

isTypeEqualTo :: Expr -> Type -> TCM Type #

Check that an expression is a type which is equal to a given type.

leqType_ :: Type -> Type -> TCM () #

Telescopes

checkTelescope :: Telescope -> (Telescope -> TCM a) -> TCM a #

Type check a (module) telescope. Binds the variables defined by the telescope.

checkPiTelescope :: Telescope -> (Telescope -> TCM a) -> TCM a #

Type check the telescope of a dependent function type. Binds the resurrected variables defined by the telescope. The returned telescope is unmodified (not resurrected).

data LamOrPi #

Flag to control resurrection on domains.

Constructors

LamNotPi

We are checking a module telescope. We pass into the type world to check the domain type. This resurrects the whole context.

PiNotLam

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

Instances
Eq LamOrPi # 
Instance details

Defined in Agda.TypeChecking.Rules.Term

Methods

(==) :: LamOrPi -> LamOrPi -> Bool #

(/=) :: LamOrPi -> LamOrPi -> Bool #

Show LamOrPi # 
Instance details

Defined in Agda.TypeChecking.Rules.Term

checkTelescope' :: LamOrPi -> Telescope -> (Telescope -> TCM a) -> TCM a #

Type check a telescope. Binds the variables defined by the telescope.

checkTypedBindings :: LamOrPi -> TypedBindings -> (Telescope -> TCM a) -> TCM a #

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 wether we check a typed lambda or a Pi. This flag is needed for irrelevance.

Lambda abstractions

checkLambda :: Arg TypedBinding -> Expr -> Type -> TCM Term #

Type check a lambda expression.

lambdaIrrelevanceCheck :: LensRelevance dom => ArgInfo -> dom -> TCM ArgInfo #

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.

checkPostponedLambda :: Arg ([WithHiding Name], Maybe Type) -> Expr -> Type -> TCM Term #

Checking a lambda whose domain type has already been checked.

insertHiddenLambdas #

Arguments

:: Hiding

Expected hiding.

-> Type

Expected to be a function type.

-> (MetaId -> Type -> TCM Term)

Continuation on blocked type.

-> (Type -> TCM Term)

Continuation when expected hiding found. The continuation may assume that the Type is of the form (El _ (Pi _ _)).

-> TCM Term

Term with hidden lambda inserted.

Insert hidden lambda until the hiding info of the domain type matches the expected hiding info. Throws WrongHidingInLambda

checkAbsurdLambda :: ExprInfo -> Hiding -> Expr -> Type -> TCM Term #

checkAbsurdLambda i h e t checks absurd lambda against type t. Precondition: e = AbsurdLam i h

checkExtendedLambda :: ExprInfo -> DefInfo -> QName -> [Clause] -> Expr -> Type -> TCM Term #

checkExtendedLambda i di qname cs e t check pattern matching lambda. Precondition: e = ExtendedLam i di qname cs

catchIlltypedPatternBlockedOnMeta :: TCM a -> ((TCErr, MetaId) -> TCM a) -> TCM a #

Run a computation.

  • If successful, return Nothing.
  • If IlltypedPattern p a, NotADatatype a or CannotEliminateWithPattern p a is thrown and type a is blocked on some meta x, reset any changes to the state and return Just x.
  • If SplitError (UnificationStuck c tel us vs _) is thrown and the unification problem us =?= vs : tel is blocked on some meta x return Just x.
  • If another error was thrown or the type a is 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.

If --sharing is enabled, we will never catch errors since it's not safe to roll back the state.

Records

checkRecordExpression :: RecordAssigns -> Expr -> Type -> TCM Term #

checkRecordExpression fs e t checks record construction against type t. Precondition e = Rec _ fs.

checkRecordUpdate :: ExprInfo -> Expr -> Assigns -> Expr -> Type -> TCM Term #

checkRecordUpdate ei recexpr fs e t Precondition e = RecUpdate ei recexpr fs.

Literal

Terms

scopedExpr :: Expr -> TCM Expr #

Remove top layers of scope info of expression and set the scope accordingly in the TCState.

checkExpr :: Expr -> Type -> TCM Term #

Type check an expression.

Reflection

quoteGoal :: Type -> TCM (Either [MetaId] Term) #

DOCUMENT ME!

quoteContext :: TCM (Either [MetaId] Term) #

DOCUMENT ME!

unquoteM :: Expr -> Term -> Type -> TCM Term -> TCM Term #

Unquote a TCM computation in a given hole.

unquoteTactic :: Term -> Term -> Type -> TCM Term -> TCM Term #

DOCUMENT ME!

Meta variables

checkQuestionMark :: (Type -> TCM (MetaId, Term)) -> Type -> MetaInfo -> InteractionId -> TCM Term #

Check an interaction point without arguments.

checkUnderscore :: Type -> MetaInfo -> TCM Term #

Check an underscore without arguments.

checkMeta :: (Type -> TCM (MetaId, Term)) -> Type -> MetaInfo -> TCM Term #

Type check a meta variable.

inferMeta :: (Type -> TCM (MetaId, Term)) -> MetaInfo -> TCM (Elims -> Term, Type) #

Infer the type of a meta variable. If it is a new one, we create a new meta for its type.

checkOrInferMeta :: (Type -> TCM (MetaId, Term)) -> Maybe Type -> MetaInfo -> TCM (Term, 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.

domainFree :: ArgInfo -> Name -> LamBinding #

Turn a domain-free binding (e.g. lambda) into a domain-full one, by inserting an underscore for the missing type.

checkKnownArguments #

Arguments

:: [NamedArg Expr]

User-supplied arguments (hidden ones may be missing).

-> Args

Inferred arguments (including hidden ones).

-> Type

Type of the head (must be Pi-type with enough domains).

-> TCM (Args, Type)

Remaining inferred arguments, remaining type.

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 #

Arguments

:: NamedArg Expr

User-supplied argument.

-> Args

Inferred arguments (including hidden ones).

-> Type

Type of the head (must be Pi-type with enough domains).

-> TCM (Args, Type)

Remaining inferred arguments, remaining type.

Check an argument whose value we already know.

checkNamedArg :: NamedArg Expr -> Type -> TCM Term #

Check a single argument.

inferExpr :: Expr -> TCM (Term, Type) #

Infer the type of an expression. Implemented by checking against a meta variable. Except for neutrals, for them a polymorphic type is inferred.

checkDontExpandLast :: Expr -> Type -> TCM Term #

Used to check aliases f = e. Switches off ExpandLast for the checking of top-level application.

isModuleFreeVar :: Int -> TCM Bool #

Check whether a de Bruijn index is bound by a module telescope.

inferExprForWith :: Expr -> TCM (Term, Type) #

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.

Let bindings