summaryrefslogtreecommitdiff
path: root/src/Grasp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Grasp')
-rw-r--r--src/Grasp/Parser.hs36
-rw-r--r--src/Grasp/Types.hs41
2 files changed, 42 insertions, 35 deletions
diff --git a/src/Grasp/Parser.hs b/src/Grasp/Parser.hs
index 1ddbb94..9bea358 100644
--- a/src/Grasp/Parser.hs
+++ b/src/Grasp/Parser.hs
@@ -1,10 +1,5 @@
module Grasp.Parser (
- GraspProgram(..),
- GraspData(..),
-
parseGrasp,
- nodesWithName,
- iso,
dup
) where
@@ -19,12 +14,11 @@ import Data.Graph.Inductive.Graph as Graph
import Data.Graph.Inductive.Tree
import Data.List
import Data.Maybe
+import Grasp.Types
-type GraspProgram = Gr String String
-
type StrLNode a = (String,a)
type StrLEdge a = (String,String,a)
@@ -33,12 +27,6 @@ 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))
-
-
-
parseGrasp :: String -> Either ParseError GraspProgram
parseGrasp input =
@@ -99,28 +87,6 @@ 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
diff --git a/src/Grasp/Types.hs b/src/Grasp/Types.hs
new file mode 100644
index 0000000..0211281
--- /dev/null
+++ b/src/Grasp/Types.hs
@@ -0,0 +1,41 @@
+module Grasp.Types (
+ GraspProgram(..),
+
+ nodesWithName,
+ normalise,
+ iso
+ ) where
+
+
+import Data.Graph.Inductive.Graph( Node, LNode, LEdge, (&) )
+import qualified Data.Graph.Inductive.Graph as Graph
+import Data.Graph.Inductive.Tree
+import Data.List
+
+
+
+
+type GraspProgram = Gr String 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))
+
+
+
+
+nodesWithName :: GraspProgram -> String -> [LNode String]
+nodesWithName g s = []
+
+
+
+normalise :: GraspProgram -> GraspProgram
+normalise g = Graph.mkGraph [] []
+
+
+
+iso :: GraspProgram -> GraspProgram -> Bool
+iso a b = (normalise a) == (normalise b)
+