summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-05-12 20:20:29 +1000
committerJed Barber <jjbarber@y7mail.com>2014-05-12 20:20:29 +1000
commitb390293df9db7997fba3da03dea70377eebb8caa (patch)
treeacdbb48d52a7918455fe211e6fb50447b8dc1912
parent4a5d01677ae457425336bf7de6ddffadf09bae83 (diff)
Garbage collection function
-rw-r--r--src/Grasp/Interpreter.hs9
1 files 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
+