diff options
author | Jed Barber <jjbarber@y7mail.com> | 2012-09-28 00:46:11 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2012-09-28 00:46:11 +1000 |
commit | 02060edfb27d906035215f9afd0f1bf13838264c (patch) | |
tree | 631a56d51c54eba130c15a05eac6f04f69122e6d /Library/TypeVar.hs | |
parent | 4146476e6fb7d07f13c29d3cc9ecf4addf2cbc99 (diff) |
Type alpha equivalence in limbo
Diffstat (limited to 'Library/TypeVar.hs')
-rw-r--r-- | Library/TypeVar.hs | 13 |
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) |