Make Expression an instance of Eq typeclass

This commit is contained in:
Joscha 2017-11-12 23:36:21 +00:00
parent a23a0ed008
commit 6cf3c70a44

View file

@ -33,8 +33,12 @@ instance (Show s) => Show (Expression s) where
show_ c (ELambda s e@(EExpr _ _)) = "\\" ++ s ++ ".(" ++ show_ (s : c) e ++ ")"
show_ c (ELambda s e) = "\\" ++ s ++ "." ++ show_ (s : c) e
instance (Eq s) => Eq (Expression s) where
-- TODO: Implement this
instance Eq (Expression s) where
(ESymbol _) == (ESymbol _) = True
(EReference a) == (EReference b) = a == b
(EExpr a b) == (EExpr c d) = a == c && b == d
(ELambda _ a) == (ELambda _ b) = a == b
_ == _ = False
insertExpr :: Expression s -> Expression s -> Expression s
insertExpr = insert_ 0