Skip to content
Browse files

fixes list equality (adds equality for type constructors without type…

… parameter)
  • Loading branch information...
1 parent fc29d30 commit 508b98d57f203575577ba11e34ead66e8ce808fc @kmels committed
View
3 src/Language/Core/Interpreter/Libraries/GHC/Classes.hs
@@ -30,11 +30,12 @@ equals = (id, Right $ Fun (monomophy_2 "(==)" valEq) "polymorphic(==)") where
valEq :: Value -> Value -> IM Value
valEq v@(Wrong _) _ = return v
valEq _ w@(Wrong _) = return w
+ valEq (TypeConstructor datacon id) (TypeConstructor datacon2 id2) = do return $ Boolean $ datacon == datacon2 && id == id2
valEq (TyConApp dc1 ps) (TyConApp dc2 ps2) | dc1 == dc2 && length ps == length ps2 = do
-- get the value of every pointer
ps_vals <- mapM (flip eval []) ps
ps2_vals <- mapM (flip eval []) ps2
-
+
-- compare every corresponding pointer value, they must be all equal
mapM (uncurry valEq) (ps_vals `zip` ps2_vals) >>= return . Boolean . Data.List.all ((==) $ Boolean $ True)
| otherwise = return . Boolean $ False
View
2 src/Language/Core/Interpreter/Structures.hs
@@ -125,7 +125,7 @@ data Value = Wrong String
| MkListOfValues [(String,Value)] -- When a value definition is recursive, depends on other values
| SumType [DataCon] -- A data type with reference to its constructors, created only from type constructors when reading modules (see Interpreter/Acknowledge).
| TypeConstructor DataCon Id -- A single data constructor that withholds, apart of its data constructor value, the qualified name of the type it builds. For example (:) is a type constructor for the list type, "[a]".
-
+
newtype Pointer = MkPointer { ptr_address :: HeapAddress } deriving Show
data Thunk = Thunk Exp Env -- a thunk created during the evaluation of a value definition

0 comments on commit 508b98d

Please sign in to comment.
Something went wrong with that request. Please try again.