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

Safe Haskell | None
Language | Haskell2010

Agda.TypeChecking.Rules.LHS

Synopsis

- flexiblePatterns :: [NamedArg Pattern] -> TCM FlexibleVars
- class IsFlexiblePattern a where
- updateInPatterns :: [Dom Type] -> [NamedArg Pattern] -> [Arg DeBruijnPattern] -> TCM ([NamedArg Pattern], [DotPatternInst])
- isSolvedProblem :: Problem -> Bool
- noShadowingOfConstructors :: Call -> Problem -> TCM ()
- checkDotPattern :: DotPatternInst -> TCM ()
- type Projectn = (ProjOrigin, QName)
- type Projectns = [Projectn]
- checkLeftoverDotPatterns :: [NamedArg Pattern] -> [Int] -> [Dom Type] -> [DotPatternInst] -> TCM ()
- bindLHSVars :: [NamedArg Pattern] -> Telescope -> TCM a -> TCM a
- bindAsPatterns :: [AsBinding] -> TCM a -> TCM a
- data LHSResult = LHSResult {
  - lhsParameters :: Nat
  - lhsVarTele :: Telescope
  - lhsPatterns :: [NamedArg DeBruijnPattern]
  - lhsBodyType :: Arg Type
  - lhsPatSubst :: Substitution
  - lhsAsBindings :: [AsBinding]
  }
- checkLeftHandSide :: Call -> Maybe QName -> [NamedArg Pattern] -> Type -> Maybe Substitution -> (LHSResult -> TCM a) -> TCM a
- checkLHS :: Maybe QName -> LHSState -> TCM LHSState
- noPatternMatchingOnCodata :: [NamedArg DeBruijnPattern] -> TCM ()

# Documentation

flexiblePatterns :: [NamedArg Pattern] -> TCM FlexibleVars #

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 #

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

Minimal complete definition

maybeFlexiblePattern

Methods

maybeFlexiblePattern :: a -> MaybeT TCM FlexibleVarKind #

isFlexiblePattern :: a -> TCM Bool #

Instances

IsFlexiblePattern Pattern # |
Methods maybeFlexiblePattern :: Pattern -> MaybeT TCM FlexibleVarKind # isFlexiblePattern :: Pattern -> TCM Bool #
IsFlexiblePattern a => IsFlexiblePattern [a] # | Lists of flexible patterns are `RecordFlex`.
Methods maybeFlexiblePattern :: [a] -> MaybeT TCM FlexibleVarKind # isFlexiblePattern :: [a] -> TCM Bool #
IsFlexiblePattern a => IsFlexiblePattern (Arg a) # |
Methods maybeFlexiblePattern :: Arg a -> MaybeT TCM FlexibleVarKind # isFlexiblePattern :: Arg a -> TCM Bool #
IsFlexiblePattern (Pattern' a) # |
Methods maybeFlexiblePattern :: Pattern' a -> MaybeT TCM FlexibleVarKind # isFlexiblePattern :: Pattern' a -> TCM Bool #
IsFlexiblePattern a => IsFlexiblePattern (Named name a) # |
Methods maybeFlexiblePattern :: Named name a -> MaybeT TCM FlexibleVarKind # isFlexiblePattern :: Named name a -> TCM Bool #

updateInPatterns #

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.

isSolvedProblem :: Problem -> Bool #

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

noShadowingOfConstructors #

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.

checkDotPattern :: DotPatternInst -> TCM () #

Check that a dot pattern matches it's instantiation.

type Projectn = (ProjOrigin, QName) #

Temporary data structure for `checkLeftoverPatterns`

type Projectns = [Projectn] #

checkLeftoverDotPatterns #

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 #

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 `ConP`s resulting from eta expanded implicit record patterns.

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

Bind as patterns

data LHSResult #

Result of checking the LHS of a clause.

Constructors

LHSResult |
Fields lhsParameters :: Nat The number of original module parameters. These are present in the the patterns. lhsVarTele :: Telescope Δ : The types of the pattern variables, in internal dependency order. Corresponds to `clauseTel`. lhsPatterns :: [NamedArg DeBruijnPattern] The patterns in internal syntax. lhsBodyType :: Arg Type The type of the body. Is `bσ` if `Γ` is defined. `Irrelevant` to indicate the rhs must be checked in irrelevant mode. lhsPatSubst :: Substitution Substitution version of `lhsPatterns`, only up to the first projection pattern. `Δ |- lhsPatSubst : Γ`. Where `Γ` is the argument telescope of the function. This is used to update inherited dot patterns in with-function clauses. lhsAsBindings :: [AsBinding] As-bindings from the left-hand side. Return instead of bound since we want them in where's and right-hand sides, but not in with-clauses (Issue 2303).

Instances

InstantiateFull LHSResult # |
Methods instantiateFull' :: LHSResult -> ReduceM LHSResult #

checkLeftHandSide #

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`.
-> Maybe Substitution | Module parameter substitution from with-abstraction.
-> (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.

checkLHS #

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

noPatternMatchingOnCodata :: [NamedArg DeBruijnPattern] -> TCM () #

Ensures that we are not performing pattern matching on codata.