egison-5.0.0: Programming language with non-linear pattern-matching against non-free data
LicenseMIT
Safe HaskellNone
LanguageGHC2021

Language.Egison.Type.Unify

Description

This module provides type unification for the Egison type system.

Synopsis

Documentation

unify :: Type -> Type -> Either UnifyError Subst Source #

Unify two types, returning a substitution if successful This is a wrapper around unifyWithConstraints with empty constraints Discards the flag since it's not needed in basic unification

unifyStrict :: Type -> Type -> Either UnifyError Subst Source #

Strict unification that does NOT allow Tensor a to unify with a This is a wrapper around unifyStrictWithConstraints with empty constraints This is used for checking type class instances in TensorMapInsertion to ensure that Tensor types are properly distinguished from scalar types

unifyStrictWithConstraints :: ClassEnv -> [Constraint] -> Type -> Type -> Either UnifyError Subst Source #

Strict unification with type class constraints This is like unifyStrict but considers type class constraints when unifying type variables. IMPORTANT: This does NOT allow Tensor a to unify with a (strict unification). When unifying a constrained type variable with Tensor type, it checks if Tensor has instances for all the constraints.

unifyWithTopLevel :: Type -> Type -> Either UnifyError Subst Source #

Unify two types, allowing Tensor a to unify with a at top-level definitions This is used only for top-level definitions with type annotations According to type-tensor-simple.md: "トップレベル定義のテンソルについてのみ、Tensor a型が a型とunifyするとa型になる。"

unifyWithConstraints :: ClassEnv -> [Constraint] -> Type -> Type -> Either UnifyError (Subst, Bool) Source #

Unify two types while considering type class constraints This function chooses unifiers that satisfy type class constraints Specifically, when unifying Tensor a with a constrained type variable t: - If C t constraint exists and C (Tensor a) is not satisfiable, prefer t = a over t = Tensor a Returns (Subst, Bool) where Bool indicates if Tensor was unwrapped during unification

unifyMany :: [Type] -> [Type] -> Either UnifyError Subst Source #

Unify a list of type pairs

data UnifyError Source #

Unification errors

Constructors

OccursCheck TyVar Type

Infinite type detected

TypeMismatch Type Type

Types cannot be unified

Instances

Instances details
Show UnifyError Source # 
Instance details

Defined in Language.Egison.Type.Unify

Eq UnifyError Source # 
Instance details

Defined in Language.Egison.Type.Unify