Safe Haskell | None |
---|---|
Language | Haskell2010 |
- 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 => SourceInj (TypeVT src) src => Type src vs t -> (TypeT src vs, [TypeT src vs])
- unifyType :: forall ki x y vs src. SourceInj (TypeVT src) src => ErrorInj (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 Subst
s.
NOTE: the union is left-biased: in case of duplicate Var
s,
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
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 Type
s cannot be unified.
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 |
Source src => Eq (Error_Unify src) Source # | |
Source src => Show (Error_Unify src) Source # | |
ErrorInj (Con_Kind src) (Error_Unify src) Source # | |
ErrorInj (Error_Unify src) (Error_Unify src) Source # | |
ErrorInj (Error_Unify src) (Error_Beta src) # | |