| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Agda.TypeChecking.Rules.LHS.Unify
- type UnificationResult = UnificationResult' Substitution
- data UnificationResult' a
- newtype Unify a = U {}
- data UnifyMayPostpone
- type UnifyEnv = UnifyMayPostpone
- emptyUEnv :: UnifyEnv
- noPostponing :: Unify a -> Unify a
- askPostpone :: Unify UnifyMayPostpone
- type UnifyOutput = Unifiable
- data Unifiable
- reportPostponing :: Unify ()
- ifClean :: Unify () -> Unify a -> Unify a -> Unify a
- data Equality = Equal TypeHH Term Term
- type Sub = IntMap Term
- data UnifyException
- data UnifyState = USt {}
- emptyUState :: UnifyState
- projectionMismatch :: QName -> QName -> Unify a
- constructorMismatch :: Type -> Term -> Term -> Unify a
- constructorMismatchHH :: TypeHH -> Term -> Term -> Unify a
- getSub :: Unify Sub
- modSub :: (Sub -> Sub) -> Unify ()
- checkEqualities :: [Equality] -> TCM ()
- checkEquality :: Type -> Term -> Term -> TCM ()
- checkEqualityHH :: TypeHH -> Term -> Term -> Unify ()
- forceHom :: TypeHH -> TCM Type
- makeHom :: TypeHH -> TCM (Maybe Type)
- tryHom :: TypeHH -> Term -> Term -> TCM TermHH
- addEquality :: Type -> Term -> Term -> Unify ()
- addEqualityHH :: TypeHH -> Term -> Term -> Unify ()
- takeEqualities :: Unify [Equality]
- occursCheck :: Nat -> Term -> Type -> Unify ()
- (|->) :: Nat -> (Term, Type) -> Unify ()
- makeSubstitution :: Sub -> Substitution
- class UReduce t where
- flattenSubstitution :: Substitution -> Substitution
- data HomHet a
- isHom :: HomHet a -> Bool
- fromHom :: HomHet a -> a
- leftHH :: HomHet a -> a
- rightHH :: HomHet a -> a
- type TermHH = HomHet Term
- type TypeHH = HomHet Type
- type TelHH = Tele (Dom TypeHH)
- type TelViewHH = TelV TypeHH
- type ArgsHH = HomHet Args
- absAppHH :: SubstHH t tHH => Abs t -> TermHH -> tHH
- class ApplyHH t where
- substHH :: SubstHH t tHH => TermHH -> t -> tHH
- class SubstHH t tHH where
- substUnderHH :: Nat -> TermHH -> t -> tHH
- trivialHH :: t -> tHH
- unifyIndices_ :: MonadTCM tcm => FlexibleVars -> Type -> Args -> Args -> tcm Substitution
- unifyIndices :: MonadTCM tcm => FlexibleVars -> Type -> Args -> Args -> tcm UnificationResult
- dataOrRecordType :: ConHead -> Type -> TCM (Maybe Type)
- dataOrRecordType' :: ConHead -> Type -> TCM (Maybe (QName, Type, Args, Args))
- dataOrRecordTypeHH :: ConHead -> TypeHH -> TCM (Maybe TypeHH)
- dataOrRecordTypeHH' :: ConHead -> TypeHH -> TCM (Maybe (QName, Type, HomHet (Args, Args)))
- isEtaRecordTypeHH :: MonadTCM tcm => TypeHH -> tcm (Maybe (QName, HomHet Args))
- data ShapeView a
- shapeView :: Type -> Unify (Type, ShapeView Type)
- shapeViewHH :: TypeHH -> Unify (TypeHH, ShapeView TypeHH)
- telViewUpToHH :: Int -> TypeHH -> Unify TelViewHH
Documentation
type UnificationResult = UnificationResult' Substitution Source
Result of unifyIndices.
data UnificationResult' a Source
Monad for unification.
Constructors
| U | |
Fields | |
data UnifyMayPostpone Source
Constructors
| MayPostpone | |
| MayNotPostpone |
type UnifyEnv = UnifyMayPostpone Source
noPostponing :: Unify a -> Unify a Source
type UnifyOutput = Unifiable Source
Output the result of unification (success or maybe).
Were two terms unifiable or did we have to postpone some equation such that we are not sure?
Constructors
| Definitely | Unification succeeded. |
| Possibly | Unification did not fail, but we had to postpone a part. |
reportPostponing :: Unify () Source
Tell that something could not be unified right now,
so the unification succeeds only Possibly.
ifClean :: Unify () -> Unify a -> Unify a -> Unify a Source
Check whether unification proceeded without postponement.
data UnifyException Source
projectionMismatch :: QName -> QName -> Unify a Source
Throw-away error message.
checkEqualities :: [Equality] -> TCM () Source
checkEquality :: Type -> Term -> Term -> TCM () Source
Force equality now instead of postponing it using addEquality.
checkEqualityHH :: TypeHH -> Term -> Term -> Unify () Source
Try equality. If constraints remain, postpone (enter unsafe mode). Heterogeneous equalities cannot be tried nor reawakened, so we can throw them away and flag "dirty".
forceHom :: TypeHH -> TCM Type Source
Check whether heterogeneous situation is really homogeneous. If not, give up.
makeHom :: TypeHH -> TCM (Maybe Type) Source
Check whether heterogeneous situation is really homogeneous. If not, return Nothing.
tryHom :: TypeHH -> Term -> Term -> TCM TermHH Source
Try to make a possibly heterogeneous term situation homogeneous.
occursCheck :: Nat -> Term -> Type -> Unify () Source
Includes flexible occurrences, metas need to be solved. TODO: relax? TODO: later solutions may remove flexible occurences
Apply the current substitution on a term and reduce to weak head normal form.
Instances
flattenSubstitution :: Substitution -> Substitution Source
Take a substitution σ and ensure that no variables from the domain appear in the targets. The context of the targets is not changed. TODO: can this be expressed using makeSubstitution and applySubst?
Are we in a homogeneous (one type) or heterogeneous (two types) situation?
Instances
| Functor HomHet Source | |
| Foldable HomHet Source | |
| Traversable HomHet Source | |
| SubstHH Type (HomHet Type) Source | |
| SubstHH Term (HomHet Term) Source | |
| Eq a => Eq (HomHet a) Source | |
| Ord a => Ord (HomHet a) Source | |
| Show a => Show (HomHet a) Source | |
| Subst a => Subst (HomHet a) Source | |
| PrettyTCM a => PrettyTCM (HomHet a) Source | |
| UReduce t => UReduce (HomHet t) Source | |
| (Free a, Subst a) => SubstHH (HomHet a) (HomHet a) Source |
class SubstHH t tHH where Source
substHH u t substitutes u for the 0th variable in t.
Instances
| SubstHH Type (HomHet Type) Source | |
| SubstHH Term (HomHet Term) Source | |
| SubstHH a b => SubstHH (Tele a) (Tele b) Source | |
| SubstHH a b => SubstHH (Abs a) (Abs b) Source | |
| SubstHH a b => SubstHH (Dom a) (Dom b) Source | |
| SubstHH a b => SubstHH (Arg a) (Arg b) Source | |
| (Free a, Subst a) => SubstHH (HomHet a) (HomHet a) Source | |
| (SubstHH a a', SubstHH b b') => SubstHH (a, b) (a', b') Source |
unifyIndices_ :: MonadTCM tcm => FlexibleVars -> Type -> Args -> Args -> tcm Substitution Source
Unify indices.
In unifyIndices_ flex a us vs,
a is the type eliminated by us and vs
(usally the type of a constructor),
need not be reduced,
us and vs are the argument lists to unify,
flex is the set of flexible (instantiable) variabes in us and vs.
The result is the most general unifier of us and vs.
unifyIndices :: MonadTCM tcm => FlexibleVars -> Type -> Args -> Args -> tcm UnificationResult Source
Arguments
| :: ConHead | Constructor name. |
| -> Type | Type of constructor application (must end in data/record). |
| -> TCM (Maybe Type) | Type of constructor, applied to pars. |
Given the type of a constructor application the corresponding data or record type, applied to its parameters (extracted from the given type), is returned.
Precondition: The type has to correspond to an application of the given constructor.
Arguments
| :: ConHead | Constructor name. |
| -> TypeHH | Type(s) of constructor application (must end in same data/record). |
| -> TCM (Maybe TypeHH) | Type of constructor, instantiated possibly heterogeneously to parameters. |
Heterogeneous situation.
a1 and a2 need to end in same datatype/record.
isEtaRecordTypeHH :: MonadTCM tcm => TypeHH -> tcm (Maybe (QName, HomHet Args)) Source
Return record type identifier if argument is a record type.
Views an expression (pair) as type shape. Fails if not same shape.
shapeView :: Type -> Unify (Type, ShapeView Type) Source
Return the type and its shape. Expects input in (u)reduced form.