disco-0.1.6: Functional programming language for teaching discrete math.
Copyrightdisco team and contributors
LicenseBSD-3-Clause
Maintainerbyorgey@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Disco.Typecheck.Unify

Description

Unification.

Synopsis

Documentation

unify :: TyDefCtx -> [(Type, Type)] -> Maybe S Source #

Given a list of equations between types, return a substitution which makes all the equations satisfied (or fail if it is not possible).

This is not the most efficient way to implement unification but it is simple.

weakUnify :: TyDefCtx -> [(Type, Type)] -> Maybe S Source #

Given a list of equations between types, return a substitution which makes all the equations equal *up to* identifying all base types. So, for example, Int = Nat weakly unifies but Int = (Int -> Int) does not. This is used to check whether subtyping constraints are structurally sound before doing constraint simplification/solving, to ensure termination.

unify' :: (BaseTy -> BaseTy -> Bool) -> TyDefCtx -> [(Type, Type)] -> Maybe S Source #

Given a list of equations between types, return a substitution which makes all the equations satisfied (or fail if it is not possible), up to the given comparison on base types.