purescript-0.8.1.0: PureScript Programming Language Compiler

Safe HaskellNone
LanguageHaskell98

Language.PureScript.TypeChecker.Unify

Description

Functions and instances relating to unification

Synopsis

Documentation

freshType :: MonadState CheckState m => m Type Source

Generate a fresh type variable

solveType :: (Functor m, Applicative m, 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

unifyTypes :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m () Source

Unify two types, updating the current substitution

unifyRows :: forall m. (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m () Source

Unify two rows, updating the current substitution

Common labels are first identified, and unified. Remaining labels and types are unified with a trailing row unification variable, if appropriate, otherwise leftover labels result in a unification error.

unifiesWith :: Type -> Type -> Bool Source

Check that two types unify

replaceVarWithUnknown :: MonadState CheckState m => String -> Type -> m Type Source

Replace a single type variable with a new unification variable

replaceTypeWildcards :: (Functor m, Applicative m, 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