summaryrefslogtreecommitdiff
path: root/Library/TypeVar.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Library/TypeVar.hs')
-rw-r--r--Library/TypeVar.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/Library/TypeVar.hs b/Library/TypeVar.hs
index 078d5d3..e8ce972 100644
--- a/Library/TypeVar.hs
+++ b/Library/TypeVar.hs
@@ -34,7 +34,7 @@ data TypeOp = TypeOp { tyOp :: Name } deriving (Eq, Ord)
data Type = TypeVar { typeVar :: Name }
| AType { aType :: [Type]
- , aTypeOp :: TypeOp } deriving (Eq, Ord)
+ , aTypeOp :: TypeOp } deriving (Ord)
data Const = Const { constName :: Name } deriving (Eq, Ord)
@@ -60,6 +60,17 @@ instance Show Var where
show (Var a _) = show a
+instance Eq Type where
+ a == b = a `typeAlphaEquiv` b
+
+
+
+typeAlphaEquiv :: Type -> Type -> Bool
+typeAlphaEquiv (TypeVar a) (TypeVar b) = True
+typeAlphaEquiv (AType alist aop) (AType blist bop) =
+ aop == bop && all (\(x,y) -> x == y) (zip alist blist)
+typeAlphaEquiv _ _ = True
+
mkEqualsType :: Type -> Type
mkEqualsType ty = typeFunc ty (typeFunc ty typeBool)