6 module Types.Data.Graph
20 import qualified Types.Data.List as L
21 import qualified Types.Data.List.Ops as L
22 import qualified Types.Data.Map as M
24 import Types.Data.Bool
25 import Types.Data.Maybe
28 -- preNodes, sucNodes: map from node ID to edge label
29 data Context preNodes nodeID nodeLabel sucNodes
31 -- nodeMap: map from node ID to context
34 -- mContext: Maybe Context
35 data Decomp mContext graph
37 -- nodeID: natural number
38 data LNode nodeID nodeLabel
40 -- lNodes: list of LNode
44 type Empty = Graph M.Empty
48 type instance IsEmpty (Graph m) = M.Null m
51 type Match node g = Match' (M.Lookup node g) node g
53 type family Match' mContext node g
54 type instance Match' Nothing node g = Decomp Nothing g
55 type instance Match' (Just (Context p node' label s)) node g
56 = Decomp (Just (Context (M.Delete node p)
60 (ClearSucc (ClearPred (M.Delete node g)
62 (M.Keys (M.Delete node s)))
64 (M.Keys (M.Delete node p)))
67 type family ClearSucc g n ns
68 type instance ClearSucc g n L.Null = g
69 type instance ClearSucc g n (L.Cons s ss)
70 = ClearSucc (M.Adjust (ClearSucc' n) s g) n ss
73 type instance L.App (ClearSucc' n) (Context ps n' l ss)
74 = Context ps n' l (M.Delete n ss)
77 type family ClearPred g n ns
78 type instance ClearPred g n L.Null = g
79 type instance ClearPred g n (L.Cons p ps)
80 = ClearPred (M.Adjust (ClearPred' n) p g) n ps
83 type instance L.App (ClearPred' n) (Context ps n' l ss)
84 = Context (M.Delete n ps) n' l ss