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

Agda.TypeChecking.Rules.LHS

Synopsis

# Documentation

Compute the set of flexible patterns in a list of patterns. The result is the deBruijn indices of the flexible patterns.

class IsFlexiblePattern a where Source #

A pattern is flexible if it is dotted or implicit, or a record pattern with only flexible subpatterns.

Minimal complete definition

maybeFlexiblePattern

Methods

Instances

 Source # Methods Source # Lists of flexible patterns are RecordFlex. MethodsisFlexiblePattern :: [a] -> TCM Bool Source # Source # Methods Source # Methods IsFlexiblePattern a => IsFlexiblePattern (Named name a) Source # MethodsisFlexiblePattern :: Named name a -> TCM Bool Source #

Arguments

 :: [Dom Type] the types of the old pattern variables, relative to the new telescope -> [NamedArg Pattern] old in patterns -> [Arg DeBruijnPattern] patterns to be substituted, living in the new telescope -> TCM ([NamedArg Pattern], [DotPatternInst])

Update the in patterns according to the given substitution, collecting new dot pattern instantiations in the process.

Check if a problem is solved. That is, if the patterns are all variables.

Arguments

 :: Call Trace, e.g., CheckPatternShadowing clause -> Problem -> TCM ()

For each user-defined pattern variable in the Problem, check that the corresponding data type (if any) does not contain a constructor of the same name (which is not in scope); this "shadowing" could indicate an error, and is not allowed.

Precondition: The problem has to be solved.

Check that a dot pattern matches it's instantiation.

Arguments

 :: [NamedArg Pattern] Leftover patterns after splitting is completed -> [Int] De Bruijn indices of leftover variable patterns computed by splitting -> [Dom Type] Types of leftover patterns -> [DotPatternInst] Instantiations computed by unifier -> TCM ()

Checks whether the dot patterns left over after splitting can be covered by shuffling around the dots from implicit positions. Returns the updated user patterns (without dot patterns).

bindLHSVars :: [NamedArg Pattern] -> Telescope -> TCM a -> TCM a Source #

Bind the variables in a left hand side and check that Hiding of the patterns matches the hiding info in the type.

Precondition: the patterns should all be VarP, WildP, or AbsurdP and the telescope should have the same size as the pattern list. There could also be ConPs resulting from eta expanded implicit record patterns.

bindAsPatterns :: [AsBinding] -> TCM a -> TCM a Source #

Bind as patterns

data LHSResult Source #

Result of checking the LHS of a clause.

Constructors

 LHSResult FieldslhsVarTele :: TelescopeΔ : The types of the pattern variables, in internal dependency order. Corresponds to clauseTel.lhsPatterns :: [NamedArg Pattern]The patterns in internal syntax.lhsBodyType :: Arg TypeThe type of the body. Is bσ if Γ is defined. Irrelevant to indicate the rhs must be checked in irrelevant mode.lhsPermutation :: PermutationThe permutation from pattern vars to Δ. Corresponds to clausePerm.

Instances

 Source # Methods

Arguments

 :: Call Trace, e.g. CheckPatternShadowing clause -> Maybe QName The name of the definition we are checking. -> [NamedArg Pattern] The patterns. -> Type The expected type a = Γ → b. -> (LHSResult -> TCM a) Continuation. -> TCM a

Check a LHS. Main function.

checkLeftHandSide a ps a ret checks that user patterns ps eliminate the type a of the defined function, and calls continuation ret if successful.

Arguments

 :: Maybe QName The name of the definition we are checking. -> LHSState The current state. -> TCM LHSState The final state after all splitting is completed

The loop (tail-recursive): split at a variable in the problem until problem is solved

Ensures that we are not performing pattern matching on codata.