From 1cd61e1840794500166d3f8c18d9010ad5564f37 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Tue, 13 May 2014 17:00:00 +1000 Subject: Improved details of garbage collection function --- src/Grasp/Interpreter.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Grasp/Interpreter.hs b/src/Grasp/Interpreter.hs index fe8b42a..e556414 100644 --- a/src/Grasp/Interpreter.hs +++ b/src/Grasp/Interpreter.hs @@ -5,6 +5,7 @@ module Grasp.Interpreter ( import Data.Graph.Inductive.Graph( Node, LNode, LEdge, (&) ) import qualified Data.Graph.Inductive.Graph as Graph +import qualified Data.Set as Set import Grasp.Types import Grasp.Parser @@ -22,14 +23,14 @@ grasp g = -reachable :: GraspProgram -> [Node] -reachable g = [] +reachable :: GraspProgram -> [IP] -> [Node] +reachable g ips = Graph.nodes g -garbageCollect :: GraspProgram -> GraspProgram -garbageCollect g = - let unreachable = (Graph.nodes g) \\ (reachable g) +garbageCollect :: GraspProgram -> [IP] -> GraspProgram +garbageCollect g ips = + let unreachable = (Graph.nodes g) \\ (reachable g ips) in Graph.delNodes unreachable g -- cgit