summaryrefslogtreecommitdiff
path: root/src/Grasp/GNode.hs
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-12-05 19:59:04 +1100
committerJed Barber <jjbarber@y7mail.com>2014-12-05 19:59:04 +1100
commit2aa0bab498cffbc12d485d2c59f7aed04c69c409 (patch)
tree49ed6dc7e2e2feedb585f52fbcfa84a97aa8c9ca /src/Grasp/GNode.hs
parente473808bb92c8f7078d17c0798f6852d4c4b881b (diff)
GNode and GEdge types now have their own files... again...
Diffstat (limited to 'src/Grasp/GNode.hs')
-rw-r--r--src/Grasp/GNode.hs60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/Grasp/GNode.hs b/src/Grasp/GNode.hs
new file mode 100644
index 0000000..3c8161e
--- /dev/null
+++ b/src/Grasp/GNode.hs
@@ -0,0 +1,60 @@
+module Grasp.GNode (
+ GNode,
+ Instruction,
+
+ mkGNode,
+ mkInst,
+
+ toNode,
+ toInst,
+ toLNode,
+
+ instToFloat
+ ) where
+
+
+
+
+import Grasp.Graph( Node, LNode )
+import Text.Read( readMaybe )
+
+
+
+
+newtype Instruction = Instruction String
+ deriving (Show, Eq)
+
+newtype GNode = GNode (LNode Instruction)
+ deriving (Show, Eq)
+
+
+
+
+mkGNode :: LNode Instruction -> GNode
+mkGNode = GNode
+
+
+
+mkInst :: String -> Instruction
+mkInst = Instruction
+
+
+
+toNode :: GNode -> Node
+toNode (GNode n) = fst n
+
+
+
+toInst :: GNode -> Instruction
+toInst (GNode n) = snd n
+
+
+
+toLNode :: GNode -> LNode Instruction
+toLNode (GNode n) = n
+
+
+
+instToFloat :: Instruction -> Maybe Float
+instToFloat (Instruction i) = readMaybe i
+