summaryrefslogtreecommitdiff
path: root/src/Grasp/GNode.hs
blob: 3c8161ea4bd8e152b9fc61b1bc03c5541984196b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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