diff options
Diffstat (limited to 'lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs')
| -rw-r--r-- | lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs b/lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs index f3fff04..96e9990 100644 --- a/lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs +++ b/lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs @@ -46,10 +46,17 @@ apply subs t = foldr (\(x, s) -> subst s x) t subs data UnifyError - = MismatchHead Text Text [Type] [Type] - | Circularity Identifier Type + = Circularity Identifier Type deriving (Show, Eq) +render :: UnifyError -> Text +render (Circularity x t) = + "Cannot unify type variable " + <> x + <> " with type " + <> pretty t + <> " due to circularity: The variable already occurs in the type." + unifyOne :: Type -> Type -> Either UnifyError Substitution unifyOne (TyVar x) (TyVar y) = if x == y then Right [] else Right [(x, TyVar y)] unifyOne (f :-> g) (f' :-> g') = |
