free-compiler-0.3.0.0: A Haskell to Coq compiler.

Safe HaskellNone
LanguageHaskell2010

FreeC.IR.Unification

Contents

Description

This module contains functions for calculating the most general unificator (mgu) of two type expressions.

Synopsis

Error Reporting

data UnificationError Source #

An error that can occur during the unification of two types.

unifyOrFail :: SrcSpan -> Type -> Type -> Converter (Subst Type) Source #

Like unify but reports a fatal error message if the types cannot be unified.

The error message uses the given location information.

unifyAllOrFail :: SrcSpan -> [Type] -> Converter (Subst Type) Source #

Like unifyAll but reports a fatal error message if the types cannot be unified.

The error message uses the given location information.

Unification

unify :: Type -> Type -> ExceptT UnificationError Converter (Subst Type) Source #

Calculates the mgu of the given type expressions.

The algorithm will preferably map the internal variable names to non-internal variables. This ensures that the names specified by the user are preserved. Otherwise variables in the first argument preferably mapped to variables in the second argument.

Type synonyms are expanded only when necessary.

unifyAll :: [Type] -> ExceptT UnificationError Converter (Subst Type) Source #

Computes the most general unificator for all given type expressions.