Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- 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 :: ki) (y :: ki) 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
class Substable a where Source #
substVarUnsafe :: src ~ SourceOf a => vs ~ VarsOf a => Var src vs v -> Type src vs v -> a -> a Source #
Like substVar
, but without the occurence check.
subst :: src ~ SourceOf a => vs ~ VarsOf a => Subst src vs -> a -> a Source #
Instances
Substable (Types src vs ts) Source # | |
Defined in Language.Symantic.Typing.Unify substVarUnsafe :: (src0 ~ SourceOf (Types src vs ts), vs0 ~ VarsOf (Types src vs ts)) => Var src0 vs0 v -> Type src0 vs0 v -> Types src vs ts -> Types src vs ts Source # subst :: (src0 ~ SourceOf (Types src vs ts), vs0 ~ VarsOf (Types src vs ts)) => Subst src0 vs0 -> Types src vs ts -> Types src vs ts Source # | |
Substable (Type src vs t) Source # | |
Defined in Language.Symantic.Typing.Unify |
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 |
Instances
Source src => Eq (Error_Unify src) Source # | |
Defined in Language.Symantic.Typing.Unify (==) :: Error_Unify src -> Error_Unify src -> Bool # (/=) :: Error_Unify src -> Error_Unify src -> Bool # | |
Source src => Show (Error_Unify src) Source # | |
Defined in Language.Symantic.Typing.Unify showsPrec :: Int -> Error_Unify src -> ShowS # show :: Error_Unify src -> String # showList :: [Error_Unify src] -> ShowS # | |
ErrorInj (Con_Kind src) (Error_Unify src) Source # | |
Defined in Language.Symantic.Typing.Unify errorInj :: Con_Kind src -> Error_Unify src # | |
ErrorInj (Error_Unify src) (Error_Unify src) Source # | |
Defined in Language.Symantic.Typing.Unify errorInj :: Error_Unify src -> Error_Unify src # | |
ErrorInj (Error_Unify src) (Error_Beta src) Source # | |
Defined in Language.Symantic.Compiling.Beta errorInj :: Error_Unify src -> Error_Beta src # |
spineTy :: forall src vs t. Source src => SourceInj (TypeVT src) src => Type src vs t -> (TypeT src vs, [TypeT src vs]) Source #
unifyType :: forall ki (x :: ki) (y :: ki) 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) Source #
Return the most general unification of two Type
s, when it exists.