License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Utilities related to type unification.
Synopsis
- data UnifyStatus
- = Apart
- | MightUnify
- | Equal
- unifyCheck :: UType -> UType -> UnifyStatus
Documentation
data UnifyStatus Source #
The result of doing a unification check on two types.
Apart | The two types are definitely not equal; they will never unify no matter how any unification variables get filled in. For example, (int * u0) and (u1 -> u2) are apart: the first is a product type and the second is a function type. |
MightUnify | The two types might unify, depending on how unification variables get filled in, but we're not sure. For example, (int * u0) and (u1 * bool). |
Equal | The two types are most definitely equal, and we don't need to bother generating a constraint to make them so. For example, (int * text) and (int * text). |
Instances
unifyCheck :: UType -> UType -> UnifyStatus Source #
Given two types, try hard to prove either that (1) they are
Apart
, i.e. cannot possibly unify, or (2) they are definitely
Equal
. In case (1), we can generate a much better error
message at the instant the two types come together than we could
if we threw a constraint into the unifier. In case (2), we don't
have to bother with generating a trivial constraint. If we don't
know for sure whether they will unify, return MightUnify
.