]> gitweb @ CieloNegro.org - hs-rrdtool.git/blob - Types/Data/Graph/RootPath.hs
Am I going the wrong way...?
[hs-rrdtool.git] / Types / Data / Graph / RootPath.hs
1 {-# LANGUAGE
2   EmptyDataDecls,
3   TypeFamilies,
4   TypeOperators,
5   UndecidableInstances
6   #-}
7 module Types.Data.Graph.RootPath
8     ( GetLPath
9     , GetDistance
10     , GetLPathNodes
11     )
12     where
13
14 import qualified Types.Data.List     as L
15 import qualified Types.Data.List.Ops as L
16
17 import Types.Data.Bool
18 import Types.Data.Graph
19 import Types.Data.Ord
20
21 -- NodeID
22 type family   NodeID lNode
23 type instance NodeID (LNode nodeID nodeLabel) = nodeID
24
25 -- NodeIDA
26 data NodeIDA
27 type instance L.App NodeIDA lNode = NodeID lNode
28
29 -- NodeLabel
30 type family   NodeLabel lNode
31 type instance NodeLabel (LNode nodeID nodeLabel) = nodeLabel
32
33 -- FindP
34 type family   FindP node lPaths
35 type instance FindP n L.Null                     = L.Null
36 type instance FindP n (L.Cons (LPath L.Null) ps) = FindP n ps
37 type instance FindP n (L.Cons (LPath (L.Cons (LNode n' l) ns)) ps)
38     = If (n :==: n')
39          (L.Cons (LNode n' l) ns)
40          (FindP n ps)
41
42 -- GetLPath
43 type GetLPath node lPaths
44     = LPath (GetLPath' node lPaths)
45
46 -- GetLPath'
47 type GetLPath' node lPaths
48     = L.Reverse (FindP node lPaths)
49
50 -- GetDistance
51 type GetDistance node lPaths
52     = NodeLabel (L.Head (FindP node lPaths))
53
54 -- GetLPathNodes
55 type GetLPathNodes node lPaths
56     = L.Map NodeIDA (GetLPath' node lPaths)