| License | MIT |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Language.Egison.Type.Unify
Description
This module provides type unification for the Egison type system.
Synopsis
- unify :: Type -> Type -> Either UnifyError Subst
- unifyStrict :: Type -> Type -> Either UnifyError Subst
- unifyStrictWithConstraints :: ClassEnv -> [Constraint] -> Type -> Type -> Either UnifyError Subst
- unifyWithTopLevel :: Type -> Type -> Either UnifyError Subst
- unifyWithConstraints :: ClassEnv -> [Constraint] -> Type -> Type -> Either UnifyError (Subst, Bool)
- unifyMany :: [Type] -> [Type] -> Either UnifyError Subst
- data UnifyError
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
data UnifyError Source #
Unification errors
Constructors
| OccursCheck TyVar Type | Infinite type detected |
| TypeMismatch Type Type | Types cannot be unified |
Instances
| Show UnifyError Source # | |
Defined in Language.Egison.Type.Unify Methods showsPrec :: Int -> UnifyError -> ShowS # show :: UnifyError -> String # showList :: [UnifyError] -> ShowS # | |
| Eq UnifyError Source # | |
Defined in Language.Egison.Type.Unify | |