summaryrefslogtreecommitdiff
path: root/src/Grasp/Monad.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Grasp/Monad.hs')
-rw-r--r--src/Grasp/Monad.hs26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/Grasp/Monad.hs b/src/Grasp/Monad.hs
index b49b53d..e58aa74 100644
--- a/src/Grasp/Monad.hs
+++ b/src/Grasp/Monad.hs
@@ -13,7 +13,9 @@ module Grasp.Monad (
peekIP,
nextIP,
- nodesOut
+ nodesOut,
+ reLabel,
+ insEdge
) where
@@ -39,7 +41,7 @@ import qualified Data.List as List
import Data.Map( Map )
import qualified Data.Map as Map
-import Grasp.Graph( Node, LNode, LEdge, Gr )
+import Grasp.Graph( Node, LNode, LEdge, Gr, (&) )
import qualified Grasp.Graph as Graph
import Grasp.Types.IP( IP )
@@ -309,3 +311,23 @@ nodesOut s n = do
if (Maybe.isNothing curNode) then return [] else return result
+
+
+reLabel :: Instruction -> GNode -> GraspM ()
+reLabel i n = do
+ (gr, ips, fh) <- State.get
+
+ let (mc, d) = Graph.match (GN.toNode n) gr
+ c = Maybe.fromJust mc
+ c' = (\(w,x,y,z) -> (w,x,i,z)) $ c
+
+ Monad.when (Maybe.isJust mc) (State.put ((c' & d) ,ips, fh))
+
+
+
+insEdge :: GEdge -> GraspM ()
+insEdge e = do
+ (gr, ips, fh) <- State.get
+ let gr' = Graph.insEdge (GE.toLEdge e) gr
+ State.put (gr', ips, fh)
+