From b390293df9db7997fba3da03dea70377eebb8caa Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 12 May 2014 20:20:29 +1000 Subject: Garbage collection function --- src/Grasp/Interpreter.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Grasp/Interpreter.hs b/src/Grasp/Interpreter.hs index 19b9a0f..fe8b42a 100644 --- a/src/Grasp/Interpreter.hs +++ b/src/Grasp/Interpreter.hs @@ -3,6 +3,8 @@ module Grasp.Interpreter ( ) where +import Data.Graph.Inductive.Graph( Node, LNode, LEdge, (&) ) +import qualified Data.Graph.Inductive.Graph as Graph import Grasp.Types import Grasp.Parser @@ -20,13 +22,16 @@ grasp g = -reachable :: GraspProgram -> [LNode String] +reachable :: GraspProgram -> [Node] reachable g = [] garbageCollect :: GraspProgram -> GraspProgram -garbageCollect g = g +garbageCollect g = + let unreachable = (Graph.nodes g) \\ (reachable g) + in Graph.delNodes unreachable g + -- cgit