diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-11-02 21:35:19 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-11-02 21:35:19 +0100 |
| commit | fc00cff556372e914d3cf15c39700b4ff7c3541c (patch) | |
| tree | 52a66d4e02a6f22748331b7eee72892e378a548b /lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs | |
| parent | 1294be22324f012e96fd1b9d5935563505c080be (diff) | |
| download | lambda-nantes-fc00cff556372e914d3cf15c39700b4ff7c3541c.tar.gz | |
better rendering for type errors and evaluation
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') = |
