ref: c40d2d87ada20043d12e9fd57a0ac0de316ebbf4
parent: 2e1a873733214b59f527208d8a34bb2bcfbabab2
author: Lennart Augustsson <lennart@augustsson.net>
date: Thu Nov 2 10:43:06 EDT 2023
Eq improvements.
--- a/src/MicroHs/Expr.hs
+++ b/src/MicroHs/Expr.hs
@@ -5,7 +5,7 @@
ImportSpec(..),
ImportItem(..),
EDef(..), showEDefs,
- Expr(..), eLam, eEqns, showExpr,
+ Expr(..), eLam, eEqns, showExpr, eqExpr,
Listish(..),
Lit(..), showLit,
EBind(..), showEBind, showEBinds,
@@ -273,9 +273,16 @@
-- XXX needs more?
eqEType :: EType -> EType -> Bool
-eqEType (EVar i) (EVar i') = i == i'
-eqEType (EApp f a) (EApp f' a') = eqEType f f' && eqEType a a'
-eqEType _ _ = False
+eqEType = eqExpr
+
+-- Very partial implementation of Expr equality.
+-- It is only used to compare instances, so this suffices.
+eqExpr :: Expr -> Expr -> Bool
+eqExpr (EVar i) (EVar i') = i == i'
+eqExpr (EVar _) (EApp _ _) = False
+eqExpr (EApp f a) (EApp f' a') = eqExpr f f' && eqExpr a a'
+eqExpr (EApp _ _) (EVar _) = False
+eqExpr _ _ = error "eqExpr: unimplemented"
---------------------------------
--- a/src/MicroHs/TypeCheck.hs
+++ b/src/MicroHs/TypeCheck.hs
@@ -341,13 +341,6 @@
eqInstDict :: InstDict -> InstDict -> Bool
eqInstDict (e, _, _) (e', _, _) = eqExpr e e'
--- Very partial implementation of Expr equality.
--- It is only used to compare instances, so this suffices.
-eqExpr :: Expr -> Expr -> Bool
-eqExpr (EVar i) (EVar i') = i == i'
-eqExpr (EApp f a) (EApp f' a') = eqExpr f f' && eqExpr a a'
-eqExpr _ _ = False
-
--------------------------
type Typed a = (a, EType)
--
⑨