Safe Haskell | None |
---|---|
Language | Haskell2010 |
A class for unification
Synopsis
- class (Eq (Tree (UVarOf m) t), RTraversable t, ZipMatch t, HasTypeConstraints t, HasQuantifiedVar t, MonadScopeConstraints (TypeConstraintsOf t) m, MonadQuantify (TypeConstraintsOf t) (QVar t) m) => Unify m t where
- binding :: BindingDict (UVarOf m) m t
- unifyError :: Tree (UnifyError t) (UVarOf m) -> m a
- structureMismatch :: (forall c. Unify m c => Tree (UVarOf m) c -> Tree (UVarOf m) c -> m (Tree (UVarOf m) c)) -> Tree (UTermBody (UVarOf m)) t -> Tree (UTermBody (UVarOf m)) t -> m ()
- unifyRecursive :: Proxy m -> Proxy t -> Dict (KNodesConstraint t (Unify m))
- type family UVarOf (m :: Type -> Type) :: Knot -> Type
- data BindingDict v m t = BindingDict {}
Documentation
class (Eq (Tree (UVarOf m) t), RTraversable t, ZipMatch t, HasTypeConstraints t, HasQuantifiedVar t, MonadScopeConstraints (TypeConstraintsOf t) m, MonadQuantify (TypeConstraintsOf t) (QVar t) m) => Unify m t where Source #
Unify m t
enables unify
to perform unification for t
in the Monad
m
.
The unifyRecursive
method represents the constraint that Unify m
applies to all recursive child nodes.
It replaces context for Unify
to avoid UndecidableSuperClasses
.
binding :: BindingDict (UVarOf m) m t Source #
The implementation for unification variables binding and lookup
unifyError :: Tree (UnifyError t) (UVarOf m) -> m a Source #
Handles a unification error.
If unifyError
is called then unification has failed.
A compiler implementation may present an error message based on the provided UnifyError
when this occurs.
structureMismatch :: (forall c. Unify m c => Tree (UVarOf m) c -> Tree (UVarOf m) c -> m (Tree (UVarOf m) c)) -> Tree (UTermBody (UVarOf m)) t -> Tree (UTermBody (UVarOf m)) t -> m () Source #
What to do when top-levels of terms being unified do not match.
Usually this will cause a unifyError
.
Some AST terms could be equivalent despite not matching structurally, like record field extentions with the fields ordered differently. Those would override the default implementation to handle the unification of mismatching structures.
unifyRecursive :: Proxy m -> Proxy t -> Dict (KNodesConstraint t (Unify m)) Source #
unifyRecursive :: KNodesConstraint t (Unify m) => Proxy m -> Proxy t -> Dict (KNodesConstraint t (Unify m)) Source #
type family UVarOf (m :: Type -> Type) :: Knot -> Type Source #
Unification variable type for a unification monad
data BindingDict v m t Source #
BindingDict implements unification variables for a type in a unification monad.
It is parameterized on:
Has 2 implementations in syntax-tree:
bindingDict
for pure state based unificationstBinding
forST
based unification