Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions and instances relating to unification
Synopsis
- freshType :: MonadState CheckState m => m SourceType
- solveType :: (MonadError MultipleErrors m, MonadState CheckState m) => Int -> SourceType -> m ()
- substituteType :: Substitution -> SourceType -> SourceType
- unknownsInType :: Type a -> [(a, Int)]
- unifyTypes :: (MonadError MultipleErrors m, MonadState CheckState m) => SourceType -> SourceType -> m ()
- unifyRows :: forall m. (MonadError MultipleErrors m, MonadState CheckState m) => SourceType -> SourceType -> m ()
- alignRowsWith :: (Type a -> Type a -> r) -> Type a -> Type a -> ([r], (([RowListItem a], Type a), ([RowListItem a], Type a)))
- replaceVarWithUnknown :: MonadState CheckState m => Text -> SourceType -> m SourceType
- replaceTypeWildcards :: (MonadWriter MultipleErrors m, MonadState CheckState m) => SourceType -> m SourceType
- varIfUnknown :: SourceType -> SourceType
Documentation
freshType :: MonadState CheckState m => m SourceType Source #
Generate a fresh type variable
solveType :: (MonadError MultipleErrors m, MonadState CheckState m) => Int -> SourceType -> m () Source #
Update the substitution to solve a type constraint
substituteType :: Substitution -> SourceType -> SourceType Source #
Apply a substitution to a type
unknownsInType :: Type a -> [(a, Int)] Source #
Compute a list of all unknowns appearing in a type
unifyTypes :: (MonadError MultipleErrors m, MonadState CheckState m) => SourceType -> SourceType -> m () Source #
Unify two types, updating the current substitution
unifyRows :: forall m. (MonadError MultipleErrors m, MonadState CheckState m) => SourceType -> SourceType -> 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 a -> Type a -> r) -> Type a -> Type a -> ([r], (([RowListItem a], Type a), ([RowListItem a], Type a))) 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 -> SourceType -> m SourceType Source #
Replace a single type variable with a new unification variable
replaceTypeWildcards :: (MonadWriter MultipleErrors m, MonadState CheckState m) => SourceType -> m SourceType Source #
Replace type wildcards with unknowns
varIfUnknown :: SourceType -> SourceType Source #
Replace outermost unsolved unification variables with named type variables