| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Mikan.TypeChecking.MetaVars
Synopsis
- findIdx :: Eq a => [a] -> a -> Maybe Int
- hasTwinMeta :: MetaId -> TCM Bool
- isBlockedTerm :: MetaId -> TCM Bool
- isEtaExpandable :: [MetaClass] -> MetaId -> TCM Bool
- assignTerm :: MetaId -> [Arg ArgName] -> Term -> TCM ()
- assignTermTCM' :: MetaId -> [Arg ArgName] -> Term -> TCM ()
- newSortMeta :: TCM Sort
- newSortMetaCtx :: MonadMetaSolver m => Args -> m Sort
- newTypeMeta' :: Comparison -> Sort -> TCM Type
- newTypeMeta :: Sort -> TCM Type
- newTypeMeta_ :: TCM Type
- newLevelMeta :: TCM Level
- newInstanceMeta :: MetaNameSuggestion -> Type -> TCM (MetaId, Term)
- newInstanceMetaCtx :: MetaNameSuggestion -> Teletype -> Args -> TCM (MetaId, Term)
- newNamedValueMeta :: RunMetaOccursCheck -> MetaNameSuggestion -> Comparison -> Type -> TCM (MetaId, Term)
- newNamedValueMeta' :: RunMetaOccursCheck -> MetaNameSuggestion -> Comparison -> Type -> TCM (MetaId, Term)
- newValueMetaOfKind :: MetaInfo -> RunMetaOccursCheck -> Comparison -> Type -> TCM (MetaId, Term)
- newValueMeta :: RunMetaOccursCheck -> Comparison -> Type -> TCM (MetaId, Term)
- newValueMetaCtx :: Frozen -> RunMetaOccursCheck -> Comparison -> Type -> Telescope -> Permutation -> Args -> TCM (MetaId, Term)
- newValueMeta' :: RunMetaOccursCheck -> Comparison -> Type -> TCM (MetaId, Term)
- newValueMetaCtx' :: Frozen -> RunMetaOccursCheck -> Comparison -> Type -> Telescope -> Permutation -> Args -> TCM (MetaId, Term)
- newTelMeta :: Telescope -> TCM Args
- newTelMetaSubst :: Telescope -> Substitution -> TCM Args
- newTelMetaCtx :: MetaNameSuggestion -> Frozen -> Telescope -> Telescope -> Permutation -> Args -> TCM Args
- newTelMetaCtxSubst :: MetaNameSuggestion -> Frozen -> Telescope -> Substitution -> Telescope -> Permutation -> Args -> TCM Args
- newRecordMeta :: QName -> Args -> TCM Term
- newRecordMetaCtx :: MetaNameSuggestion -> Frozen -> QName -> Args -> Telescope -> Permutation -> Args -> TCM Term
- newQuestionMark :: InteractionId -> Comparison -> Type -> TCM (MetaId, Term)
- newQuestionMark' :: (Comparison -> Type -> TCM (MetaId, Term)) -> InteractionId -> Comparison -> Type -> TCM (MetaId, Term)
- blockTerm :: Type -> TCM Term -> TCM Term
- blockTermOnProblem :: Type -> Term -> ProblemId -> TCM Term
- blockTypeOnProblem :: Type -> ProblemId -> TCM Type
- unblockedTester :: Type -> TCM Blocker
- postponeTypeCheckingProblem_ :: TypeCheckingProblem -> TCM Term
- postponeTypeCheckingProblem :: TypeCheckingProblem -> Blocker -> TCM Term
- problemType :: TypeCheckingProblem -> Type
- etaExpandMetaTCM :: [MetaClass] -> MetaId -> TCM ()
- etaExpandBlocked :: (MonadMetaSolver m, IsMeta t, Reduce t) => Blocked t -> m (Blocked t)
- assignWrapper :: MonadMetaSolver m => CompareDirection -> MetaId -> Elims -> Term -> m () -> m ()
- assign :: CompareDirection -> MetaId -> Args -> Term -> CompareAs -> TCM ()
- isInteractionMetaB :: MonadPretty m => MetaId -> Args -> m (Maybe (MetaId, InteractionId, Args))
- assignMeta :: Int -> MetaId -> Teletype -> [Int] -> Term -> TCM ()
- assignMeta' :: Int -> MetaId -> Teletype -> Int -> SubstCand -> Term -> TCM ()
- checkMetaInst :: MetaId -> TCM ()
- checkSolutionForMeta :: MetaId -> MetaVariable -> Term -> Type -> TCM ()
- expandProjectedVars :: (Pretty a, PrettyTCM a, NoProjectedVar a, ReduceAndEtaContract a, PrettyTCM b, TermSubst b) => a -> b -> (a -> b -> TCM c) -> TCM c
- etaExpandProjectedVar :: (PrettyTCM a, TermSubst a) => Int -> a -> TCM c -> (a -> TCM c) -> TCM c
- data ProjectedVar = ProjectedVar {
- pvIndex :: Int
- prProjs :: [(ProjOrigin, QName)]
- viewProjectedVar :: Term -> Maybe ProjectedVar
- unviewProjectedVar :: ProjectedVar -> Term
- class NoProjectedVar a where
- noProjectedVar :: a -> Either ProjectedVar ()
- class (TermLike a, TermSubst a, Reduce a) => ReduceAndEtaContract a where
- reduceAndEtaContract :: a -> TCM a
- type FVs = VarSet
- type SubstCand = [(Int, Term)]
- checkLinearity :: SubstCand -> ExceptT () TCM SubstCand
- type Res = [(Arg Nat, Term)]
- data InvertExcept
- inverseSubst' :: (Term -> Bool) -> Tele (Dom Type) -> Args -> ExceptT InvertExcept TCM SubstCand
- isFaceConstraint :: MetaId -> Args -> TCM (Maybe (MetaVariable, IntMap Bool, SubstCand, Substitution))
- tryAddBoundary :: CompareDirection -> MetaId -> InteractionId -> Args -> Term -> CompareAs -> TCM ()
- openMetasToPostulates' :: (MetaId -> MetaVariable -> Bool) -> TCM ()
- openMetasToPostulates :: TCM ()
- dependencySortMetas :: [MetaId] -> TCM (Maybe [MetaId])
Documentation
findIdx :: Eq a => [a] -> a -> Maybe Int Source #
Find position of a value in a list. Used to change metavar argument indices during assignment.
reverse is necessary because we are directly abstracting over the list.
hasTwinMeta :: MetaId -> TCM Bool Source #
Does the given local meta-variable have a twin meta-variable?
isBlockedTerm :: MetaId -> TCM Bool Source #
Check whether a meta variable is a place holder for a blocked term.
Performing the assignment
assignTerm :: MetaId -> [Arg ArgName] -> Term -> TCM () Source #
Performing the meta variable assignment.
The instantiation should not be an InstV and the MetaId
should point to something Open or a BlockedConst.
Further, the meta variable may not be Frozen.
assignTermTCM' :: MetaId -> [Arg ArgName] -> Term -> TCM () Source #
Skip frozen check. Used for eta expanding frozen metas.
Creating meta variables.
newSortMetaCtx :: MonadMetaSolver m => Args -> m Sort Source #
Create a sort meta that may be instantiated with Inf (Typeω).
newTypeMeta' :: Comparison -> Sort -> TCM Type Source #
newTypeMeta_ :: TCM Type Source #
newLevelMeta :: TCM Level Source #
newInstanceMeta :: MetaNameSuggestion -> Type -> TCM (MetaId, Term) Source #
newInstanceMeta s t cands creates a new instance metavariable
of type the output type of t with name suggestion s.
newInstanceMetaCtx :: MetaNameSuggestion -> Teletype -> Args -> TCM (MetaId, Term) Source #
newNamedValueMeta :: RunMetaOccursCheck -> MetaNameSuggestion -> Comparison -> Type -> TCM (MetaId, Term) Source #
Create a new value meta with specific dependencies, possibly η-expanding in the process.
newNamedValueMeta' :: RunMetaOccursCheck -> MetaNameSuggestion -> Comparison -> Type -> TCM (MetaId, Term) Source #
Create a new value meta with specific dependencies without η-expanding.
Arguments
| :: MetaInfo | |
| -> RunMetaOccursCheck | Ignored for instance metas. |
| -> Comparison | Ignored for instance metas. |
| -> Type | |
| -> TCM (MetaId, Term) |
newValueMeta :: RunMetaOccursCheck -> Comparison -> Type -> TCM (MetaId, Term) Source #
Create a new metavariable, possibly η-expanding in the process.
See newValueMetaCtx'.
newValueMetaCtx :: Frozen -> RunMetaOccursCheck -> Comparison -> Type -> Telescope -> Permutation -> Args -> TCM (MetaId, Term) Source #
Create a new metavariable with a provided thinning,
possibly η-expanding in the process. See newValueMetaCtx'.
newValueMeta' :: RunMetaOccursCheck -> Comparison -> Type -> TCM (MetaId, Term) Source #
Create a new metavariable without η-expanding.
See newValueMetaCtx'.
Arguments
| :: Frozen | Should the new metavariable be frozen? |
| -> RunMetaOccursCheck | Allow this meta to appear in its own solution (for interaction points, generalised variables, and instance metas). |
| -> Comparison | Are we checking or infering the type? |
| -> Type | The type of the meta, in context |
| -> Telescope | Thinned context |
| -> Permutation | Thinning |
| -> Args | A substitution |
| -> TCM (MetaId, Term) |
Create a new metavariable with a provided thinning, without η-expanding.
newTelMeta :: Telescope -> TCM Args Source #
Create a telescope of metavariables ?x0 : A, ?x1 : B ?x0, ?x2 : C ?x0 ?x1, ...
from a telescope (a : A) (b : B a) (c : C a b) ....
Arguments
| :: Telescope | A telescope of types in context |
| -> Substitution | A substitution |
| -> TCM Args |
Create a telescope of metavariables ?x0 : A, ?x1 : B ?x0, ?x2 : C ?x0 ?x1, ...
from a telescope (a : A) (b : B a) (c : C a b) ... in the current context while
applying a substitution to the telescope of types.
newTelMetaSubst tel rho is a fused version of newTelMeta (applySubst rho tel).
If you do not need to apply a substitution, use newTelMeta.
newTelMetaCtx :: MetaNameSuggestion -> Frozen -> Telescope -> Telescope -> Permutation -> Args -> TCM Args Source #
Create a telescope of metavariables ?x0 : A, ?x1 : B ?x0, ?x2 : C ?x0 ?x1, ...
from a telescope (a : A) (b : B a) (c : C a b) ... in the provided
context. See newTelMetaCtxSubst.
Arguments
| :: MetaNameSuggestion | Name suggestion to be used as a prefix of the name suggestions for the metas that represent each field. |
| -> Frozen | Should the new metavariable be frozen? |
| -> Telescope | A telescope of types in context |
| -> Substitution | A substitution |
| -> Telescope | Thinned context |
| -> Permutation | Thinning |
| -> Args | A substitution |
| -> TCM Args |
Create a telescope of metavariables ?x0 : A, ?x1 : B ?x0, ?x2 : C ?x0 ?x1, ...
from a telescope (a : A) (b : B a) (c : C a b) ... in the provided
context.
This is a low-level interface to creating telescopes of metas.
Most users will probably want to use newTelMeta or newTelMetaSubst.
Create an element of a record type by applying the constructor to fresh metavariables for each of the fields.
Arguments
| :: MetaNameSuggestion | Name suggestion to be used as a prefix of the name suggestions for the metas that represent each field |
| -> Frozen | Should the meta be created frozen? |
| -> QName | Name of record type |
| -> Args | Parameters of record type. |
| -> Telescope | Thinned context |
| -> Permutation | Thinning |
| -> Args | A substitution |
| -> TCM Term |
newQuestionMark :: InteractionId -> Comparison -> Type -> TCM (MetaId, Term) Source #
newQuestionMark' :: (Comparison -> Type -> TCM (MetaId, Term)) -> InteractionId -> Comparison -> Type -> TCM (MetaId, Term) Source #
blockTerm :: Type -> TCM Term -> TCM Term Source #
Construct a blocked constant if there are constraints.
unblockedTester :: Type -> TCM Blocker Source #
unblockedTester t returns a Blocker for t.
Auxiliary function used when creating a postponed type checking problem.
postponeTypeCheckingProblem_ :: TypeCheckingProblem -> TCM Term Source #
Create a postponed type checking problem e : t that waits for type t
to unblock (become instantiated or its constraints resolved).
postponeTypeCheckingProblem :: TypeCheckingProblem -> Blocker -> TCM Term Source #
Create a postponed type checking problem e : t that waits for conditon
unblock. A new meta is created in the current context that has as
instantiation the postponed type checking problem. An UnBlock constraint
is added for this meta, which links to this meta.
problemType :: TypeCheckingProblem -> Type Source #
Type of the term that is produced by solving the TypeCheckingProblem.
etaExpandMetaTCM :: [MetaClass] -> MetaId -> TCM () Source #
Eta-expand a local meta-variable, if it is of the specified kind. Don't do anything if the meta-variable is a blocked term.
etaExpandBlocked :: (MonadMetaSolver m, IsMeta t, Reduce t) => Blocked t -> m (Blocked t) Source #
Eta expand blocking metavariables of record type, and reduce the blocked thing.
assignWrapper :: MonadMetaSolver m => CompareDirection -> MetaId -> Elims -> Term -> m () -> m () Source #
assign :: CompareDirection -> MetaId -> Args -> Term -> CompareAs -> TCM () Source #
Miller pattern unification:
assign dir x vs v a solves problem x vs <=(dir) v : a for meta x
if vs are distinct variables (linearity check)
and v depends only on these variables
and does not contain x itself (occurs check).
This is the basic story, but we have added some features:
- Pruning.
- Benign cases of non-linearity.
vsmay contain record patterns.
For a reference to some of these extensions, read Andreas Abel and Brigitte Pientka's TLCA 2011 paper.
isInteractionMetaB :: MonadPretty m => MetaId -> Args -> m (Maybe (MetaId, InteractionId, Args)) Source #
Is the given metavariable application secretly an interaction point application? Ugly.
assignMeta :: Int -> MetaId -> Teletype -> [Int] -> Term -> TCM () Source #
assignMeta m x t ids u solves x ids = u for meta x of type t,
where term u lives in a context of length m.
Precondition: ids is linear.
assignMeta' :: Int -> MetaId -> Teletype -> Int -> SubstCand -> Term -> TCM () Source #
assignMeta' m x t ids u solves x = [ids]u for meta x of type t,
where term u lives in a context of length m,
and ids is a partial substitution.
checkMetaInst :: MetaId -> TCM () Source #
Check that the instantiation of the given metavariable fits the type of the metavariable. If the metavariable is not yet instantiated, add a constraint to check the instantiation later.
checkSolutionForMeta :: MetaId -> MetaVariable -> Term -> Type -> TCM () Source #
Check that the instantiation of the metavariable with the given term is well-typed.
Arguments
| :: (Pretty a, PrettyTCM a, NoProjectedVar a, ReduceAndEtaContract a, PrettyTCM b, TermSubst b) | |
| => a | Meta variable arguments. |
| -> b | Right hand side. |
| -> (a -> b -> TCM c) | |
| -> TCM c |
Eta-expand bound variables like z in X (fst z).
etaExpandProjectedVar :: (PrettyTCM a, TermSubst a) => Int -> a -> TCM c -> (a -> TCM c) -> TCM c Source #
Eta-expand a de Bruijn index of record type in context and passed term(s).
data ProjectedVar Source #
A de Bruijn index under some projections.
Constructors
| ProjectedVar | |
Fields
| |
Instances
| Show ProjectedVar Source # | |
Defined in Mikan.TypeChecking.MetaVars Methods showsPrec :: Int -> ProjectedVar -> ShowS # show :: ProjectedVar -> String # showList :: [ProjectedVar] -> ShowS # | |
| Eq ProjectedVar Source # | Ignore |
Defined in Mikan.TypeChecking.MetaVars | |
viewProjectedVar :: Term -> Maybe ProjectedVar Source #
class NoProjectedVar a where Source #
Check whether one of the meta args is a projected var.
Minimal complete definition
Nothing
Methods
noProjectedVar :: a -> Either ProjectedVar () Source #
default noProjectedVar :: forall b (t :: Type -> Type). (NoProjectedVar b, Foldable t, t b ~ a) => a -> Either ProjectedVar () Source #
Instances
| NoProjectedVar Term Source # | |
Defined in Mikan.TypeChecking.MetaVars Methods noProjectedVar :: Term -> Either ProjectedVar () Source # | |
| NoProjectedVar a => NoProjectedVar (Arg a) Source # | |
Defined in Mikan.TypeChecking.MetaVars Methods noProjectedVar :: Arg a -> Either ProjectedVar () Source # | |
| NoProjectedVar a => NoProjectedVar [a] Source # | |
Defined in Mikan.TypeChecking.MetaVars Methods noProjectedVar :: [a] -> Either ProjectedVar () Source # | |
class (TermLike a, TermSubst a, Reduce a) => ReduceAndEtaContract a where Source #
Normalize just far enough to be able to eta-contract maximally.
Minimal complete definition
Nothing
Methods
reduceAndEtaContract :: a -> TCM a Source #
default reduceAndEtaContract :: forall (f :: Type -> Type) b. (Traversable f, ReduceAndEtaContract b, f b ~ a) => a -> TCM a Source #
Instances
| ReduceAndEtaContract Term Source # | |
Defined in Mikan.TypeChecking.MetaVars | |
| ReduceAndEtaContract a => ReduceAndEtaContract (Arg a) Source # | |
Defined in Mikan.TypeChecking.MetaVars | |
| ReduceAndEtaContract a => ReduceAndEtaContract [a] Source # | |
Defined in Mikan.TypeChecking.MetaVars Methods reduceAndEtaContract :: [a] -> TCM [a] Source # | |
checkLinearity :: SubstCand -> ExceptT () TCM SubstCand Source #
Turn non-det substitution into proper substitution, if possible. Otherwise, raise the error.
data InvertExcept Source #
Exceptions raised when substitution cannot be inverted.
Constructors
| CantInvert Term | Cannot recover. |
| NeutralArg | A potentially neutral arg: can't invert, but can try pruning. |
| ProjVar ProjectedVar | Try to eta-expand var to remove projs. |
inverseSubst' :: (Term -> Bool) -> Tele (Dom Type) -> Args -> ExceptT InvertExcept TCM SubstCand Source #
Check that arguments args to a metavar are in pattern fragment.
Assumes all arguments already in whnf and eta-reduced.
Parameters are represented as Vars so checkArgs really
checks that all args are Vars and returns the "substitution"
to be applied to the rhs of the equation to solve.
(If args is considered a substitution, its inverse is returned.)
The returned list might not be ordered. Linearity, i.e., whether the substitution is deterministic, has to be checked separately.
isFaceConstraint :: MetaId -> Args -> TCM (Maybe (MetaVariable, IntMap Bool, SubstCand, Substitution)) Source #
If the given metavariable application represents a face, return:
- The metavariable information;
- The actual face, as an assignment of booleans to variables;
- The substitution candidate resulting from
inverseSubst'. This is guaranteed to be linear and deterministic. - The actual substitution, mapping from the constraint context to the metavariable's context.
Put concisely, a face constraint is an equation in the pattern
fragment modulo the presence of endpoints (i0 and i1) in the
telescope. In more detail, a face constraint has the form
?0 Δ (i = i0) (j = i0) Γ (k = i1) Θ (l = i0) = t
where all the greek letters consist entirely of distinct bound variables (and, of course, arbitrarily many endpoints are allowed between each substitution fragment).
tryAddBoundary :: CompareDirection -> MetaId -> InteractionId -> Args -> Term -> CompareAs -> TCM () Source #
Record a "face" equation onto an interaction point into the actual
interaction point boundary. Takes all the same arguments as
assignMeta'.
openMetasToPostulates' :: (MetaId -> MetaVariable -> Bool) -> TCM () Source #
Turn open metas into postulates.
Preconditions:
- We are
inTopContext. envCurrentModuleis set to the top-level module.
openMetasToPostulates :: TCM () Source #
Orphan instances
| MonadMetaSolver TCM Source # | |
Methods newMeta' :: MetaInstantiation -> Frozen -> MetaInfo -> MetaPriority -> Permutation -> Judgement a -> TCM MetaId Source # assignV :: CompareDirection -> MetaId -> Args -> Term -> CompareAs -> TCM () Source # assignTerm' :: MetaId -> [Arg ArgName] -> Term -> TCM () Source # etaExpandMeta :: [MetaClass] -> MetaId -> TCM () Source # updateMetaVar :: MetaId -> (MetaVariable -> MetaVariable) -> TCM () Source # speculateMetas :: TCM () -> TCM KeepMetas -> TCM () Source # | |