From 80cf4b03a4b2353de68a3adc3304334b8a7e347d Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 14 Jan 2023 23:11:59 +0100 Subject: [PATCH] unify simpler heapref cases --- app/Interpreter.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Interpreter.hs b/app/Interpreter.hs index bb47144..774c13d 100644 --- a/app/Interpreter.hs +++ b/app/Interpreter.hs @@ -129,6 +129,16 @@ proveStep = St.get >>= go unify (HeapRef _) VoidRef = uok unify VoidRef (HeapRef _) = uok {- actual HeapRefs, these are dereferenced and then unified (sometimes with copying) -} + unify (HeapRef hr) (HeapRef gr) + | BoundRef ha _ <- deref hr + , BoundRef ga _ <- deref gr + , ha == ga = uok + | FreeRef ha <- deref hr + , BoundRef ga _ <- deref gr = setHeap ha (HeapRef ga) + | BoundRef ha _ <- deref hr + , FreeRef ga <- deref gr = setHeap ga (HeapRef ha) + | FreeRef ha <- deref hr + , FreeRef ga <- deref gr = setHeap ha (HeapRef ga) unify (HeapRef hr') g = case deref hr' of FreeRef hr ->