Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions and instances relating to unification
- freshType :: MonadState CheckState m => m Type
- solveType :: (MonadError MultipleErrors m, MonadState CheckState m) => Int -> Type -> m ()
- substituteType :: Substitution -> Type -> Type
- unknownsInType :: Type -> [Int]
- unifyTypes :: (MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m ()
- unifyRows :: forall m. (MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m ()
- alignRowsWith :: (Type -> Type -> a) -> Type -> Type -> ([a], (([(Label, Type)], Type), ([(Label, Type)], Type)))
- replaceVarWithUnknown :: MonadState CheckState m => Text -> Type -> m Type
- replaceTypeWildcards :: (MonadWriter MultipleErrors m, MonadState CheckState m) => Type -> m Type
- varIfUnknown :: Type -> Type
Documentation
freshType :: MonadState CheckState m => m Type Source #
Generate a fresh type variable
solveType :: (MonadError MultipleErrors m, MonadState CheckState m) => Int -> Type -> m () Source #
Update the substitution to solve a type constraint
substituteType :: Substitution -> Type -> Type Source #
Apply a substitution to a type
unknownsInType :: Type -> [Int] Source #
Compute a list of all unknowns appearing in a type
unifyTypes :: (MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m () Source #
Unify two types, updating the current substitution
unifyRows :: forall m. (MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m () Source #
Unify two rows, updating the current substitution
Common labels are identified and unified. Remaining labels and types are unified with a trailing row unification variable, if appropriate.
alignRowsWith :: (Type -> Type -> a) -> Type -> Type -> ([a], (([(Label, Type)], Type), ([(Label, Type)], Type))) Source #
Align two rows of types, splitting them into three parts:
- Those types which appear in both rows
- Those which appear only on the left
- Those which appear only on the right
Note: importantly, we preserve the order of the types with a given label.
replaceVarWithUnknown :: MonadState CheckState m => Text -> Type -> m Type Source #
Replace a single type variable with a new unification variable
replaceTypeWildcards :: (MonadWriter MultipleErrors m, MonadState CheckState m) => Type -> m Type Source #
Replace type wildcards with unknowns
varIfUnknown :: Type -> Type Source #
Replace outermost unsolved unification variables with named type variables