A unification algorithm for types, which can take a list of (ordered) type synonyms into account.
- data UnificationError
- mgu :: Tp -> Tp -> Either UnificationError MapSubstitution
- mguWithTypeSynonyms :: OrderedTypeSynonyms -> Tp -> Tp -> Either UnificationError (Bool, MapSubstitution)
- equalUnderTypeSynonyms :: OrderedTypeSynonyms -> Tp -> Tp -> Maybe Tp
- unifiable :: OrderedTypeSynonyms -> Tp -> Tp -> Bool
- unifiableList :: OrderedTypeSynonyms -> Tps -> Bool
There are two reasons why two types cannot be unified: either two (different) type constants clash (they should be the same), or a type variable should be unified with a composed type that contains this same type variable.
The most general unification (substitution) of two types.
Find the most general type for two types that are equal under type synonyms (i.e., the least number of expansions)
Given a set of (ordered) type synonyms, can two types be unified?