]> gitweb @ CieloNegro.org - hs-rrdtool.git/blob - Data/HList/Graph.hs
major rename
[hs-rrdtool.git] / Data / HList / Graph.hs
1 {-# LANGUAGE
2   EmptyDataDecls,
3   FlexibleContexts,
4   FlexibleInstances,
5   MultiParamTypeClasses,
6   TypeFamilies
7   #-}
8 module Data.HList.Graph
9     ( Graph(..)
10     , NodeSet
11     , NodeIDSet
12     , Node(..)
13     , LPath(..)
14
15     , IsEmpty
16
17     , NodeIDA
18     )
19     where
20
21 import Data.HList.Prelude
22
23 -- NodeSet
24 class    NodeSet ns
25 instance NodeSet Nil
26 instance NodeSet ns => NodeSet (Cons n ns)
27
28 -- NodeIDSet
29 class    NoDuplicates ids => NodeIDSet ids
30 instance NodeIDSet Nil
31 instance (OccursNot id ids, NodeIDSet ids) => NodeIDSet (Cons id ids)
32
33 -- LPath (list of labeled node IDs)
34 class    LPath p
35 instance LPath Nil
36 instance LPath p => LPath (Cons (Cons l id) p)
37
38 -- Node
39 class NodeIDSet (LinksFrom n) => Node n
40     where
41       type NodeID n
42       type LinksFrom n
43
44 -- NodeIDA
45 data NodeIDA
46 instance ApplyT NodeIDA n where
47     type Apply NodeIDA n = NodeID n
48
49 -- Graph
50 class ( NodeSet (Nodes g)
51       , NoDuplicates (Map NodeIDA g)
52       )
53     => Graph g
54     where
55       type Empty g
56       type Nodes g
57
58 -- IsEmpty
59 type family IsEmpty g