diff options
Diffstat (limited to 'src/Grasp')
-rw-r--r-- | src/Grasp/Parser.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Grasp/Parser.hs b/src/Grasp/Parser.hs index e7c920d..1ddbb94 100644 --- a/src/Grasp/Parser.hs +++ b/src/Grasp/Parser.hs @@ -1,7 +1,10 @@ module Grasp.Parser ( GraspProgram(..), + GraspData(..), parseGrasp, + nodesWithName, + iso, dup ) where @@ -26,6 +29,14 @@ type StrLNode a = (String,a) type StrLEdge a = (String,String,a) +type GraspData = ([StrLNode String],[StrLEdge String]) + + + +instance (Ord a, Ord b) => Eq (Gr a b) where + a == b = ((sort . Graph.labNodes $ a) == (sort . Graph.labNodes $ b)) && + ((sort . Graph.labEdges $ a) == (sort . Graph.labEdges $ b)) + @@ -88,6 +99,28 @@ constructGraph = uncurry Graph.mkGraph +nodesWithName :: GraspProgram -> String -> [LNode String] +nodesWithName g s = [] + + + +normalise :: GraspData -> ([LNode String],[LEdge String]) +normalise (n,e) = ([],[]) + + + +iso :: GraspProgram -> GraspProgram -> Bool +iso a b = + let f (x,y) = (show x, y) + g (x,y,z) = (show x, show y, z) + + -- converts a grasp program into grasp data + h x = ((map f) . Graph.labNodes $ x, (map g) . Graph.labEdges $ x) + + in (constructGraph . normalise . h $ a) == (constructGraph . normalise . h $ b) + + + dup :: (Eq a) => [a] -> Maybe a dup x = let dup' [] _ = Nothing |