| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Symantic.Typing.Unify
- newtype Subst src vs = Subst (Map IndexVar (VT src vs))
- unionSubst :: Subst src vs -> Subst src vs -> Subst src vs
- data VT src vs = VT (Var src vs t) (Type src vs t)
- insertSubst :: Var src vs v -> Type src vs v -> Subst src vs -> Subst src vs
- lookupSubst :: Var src vs v -> Subst src vs -> Maybe (Type src vs v)
- class Substable a where
- substVar :: src ~ SourceOf a => vs ~ VarsOf a => Source src => VarOccursIn a => Substable a => Var src vs v -> Type src vs v -> a -> Maybe a
- data Error_Unify src
- = Error_Unify_Var_loop IndexVar (TypeVT src)
- | Error_Unify_Const_mismatch (TypeVT src) (TypeVT src)
- | Error_Unify_Kind_mismatch (KindK src) (KindK src)
- | Error_Unify_Kind (Con_Kind src)
- | Error_Unify_mismatch (TypeVT src) (TypeVT src)
- spineTy :: forall src vs t. Source src => Inj_Source (TypeVT src) src => Type src vs t -> (TypeT src vs, [TypeT src vs])
- unifyType :: forall ki x y vs src. Inj_Source (TypeVT src) src => Inj_Error (Con_Kind src) (Error_Unify src) => Subst src vs -> Type src vs (x :: ki) -> Type src vs (y :: ki) -> Either (Error_Unify src) (Subst src vs)
Type Subst
Type variable substitution.
WARNING: a Subst MUST be without loops, and fully expanded.
unionSubst :: Subst src vs -> Subst src vs -> Subst src vs Source #
Unify two Substs.
NOTE: the union is left-biased: in case of duplicate Vars,
it keeps the one from the first Subst given.
NOTE: the first Subst given is applied to the second (with subst),
this way each Var directly maps to an expanded Type,
so that, when using the resulting Subst,
there is no need to apply it multiple times
until there is no more substitution to be done.
Type VT
Class Substable
class Substable a where Source #
Minimal complete definition
substVar :: src ~ SourceOf a => vs ~ VarsOf a => Source src => VarOccursIn a => Substable a => Var src vs v -> Type src vs v -> a -> Maybe a Source #
Type Error_Unify
data Error_Unify src Source #
Reasons why two Types cannot be unified.
Constructors
| Error_Unify_Var_loop IndexVar (TypeVT src) | occurence check: a |
| Error_Unify_Const_mismatch (TypeVT src) (TypeVT src) | Two |
| Error_Unify_Kind_mismatch (KindK src) (KindK src) | Two |
| Error_Unify_Kind (Con_Kind src) | Two |
| Error_Unify_mismatch (TypeVT src) (TypeVT src) | Cannot unify those two |
Instances
| Source src => Eq (Error_Unify src) Source # | |
| Source src => Show (Error_Unify src) Source # | |
| Inj_Error (Con_Kind src) (Error_Unify src) Source # | |
| Inj_Error (Error_Unify src) (Error_Unify src) Source # | |
| Inj_Error (Error_Unify src) (Error_Beta src) # | |
spineTy :: forall src vs t. Source src => Inj_Source (TypeVT src) src => Type src vs t -> (TypeT src vs, [TypeT src vs]) Source #
unifyType :: forall ki x y vs src. Inj_Source (TypeVT src) src => Inj_Error (Con_Kind src) (Error_Unify src) => Subst src vs -> Type src vs (x :: ki) -> Type src vs (y :: ki) -> Either (Error_Unify src) (Subst src vs) Source #
Return the most general unification of two Types, when it exists.