]> gitweb @ CieloNegro.org - hs-rrdtool.git/blobdiff - Data/HList/Graph.hs
type-level maps and maybes
[hs-rrdtool.git] / Data / HList / Graph.hs
index ee5f613f1d5b4daea8ff4ed47dad0d643d31bb54..c3fcf87eb750f229c85951d185a25c4814ab2038 100644 (file)
@@ -1,33 +1,72 @@
 {-# LANGUAGE
-  FlexibleContexts,
-  FlexibleInstances,
+  EmptyDataDecls,
   TypeFamilies
   #-}
 module Data.HList.Graph
-    ( HNodeSet
-    , HNode(..)
-    , HGraph(..)
+    ( Context
+    , Graph
+
+    , Empty
+    , IsEmpty
+--    , Match
     )
     where
 
 import Data.HList.Prelude
+import Types.Data.Bool
 
--- HNodeSet
-class    HNodeSet ns
-instance HNodeSet HNil
-instance HNodeSet ns => HNodeSet (HCons n ns)
+-- Graph is a map from node ID to context
+data Context preNodes node sucNodes
+data Graph nodeMap
 
--- HNode
-class ( HNodeSet (HLinksFrom n)
-      )
-    => HNode n
+-- Empty
+type Empty = Graph Nil
+
+-- IsEmpty
+type family   IsEmpty g
+type instance IsEmpty (Graph Nil)         = True
+type instance IsEmpty (Graph (Cons x xs)) = False
+
+-- Match
+--type Match n g
+--    = 
+
+{-
+-- NodeSet
+class    NodeSet ns
+instance NodeSet Nil
+instance NodeSet ns => NodeSet (Cons n ns)
+
+-- NodeIDSet
+class    NoDuplicates ids => NodeIDSet ids
+instance NodeIDSet Nil
+instance (OccursNot id ids, NodeIDSet ids) => NodeIDSet (Cons id ids)
+
+-- LPath (list of labeled node IDs)
+class    LPath p
+instance LPath Nil
+instance LPath p => LPath (Cons (Cons l id) p)
+
+-- Node
+class NodeIDSet (LinksFrom n) => Node n
     where
-      type HNodeID n
-      type HLinksFrom n
+      type NodeID n
+      type LinksFrom n
 
--- HGraph
-class ( HNodeSet (HNodes g)
+-- NodeIDA
+data NodeIDA
+instance ApplyT NodeIDA n where
+    type Apply NodeIDA n = NodeID n
+
+-- Graph
+class ( NodeSet (Nodes g)
+      , NoDuplicates (Map NodeIDA g)
       )
-    => HGraph g
+    => Graph g
     where
-      type HNodes g
+      type Empty g
+      type Nodes g
+
+-- IsEmpty
+type family IsEmpty g
+-}
\ No newline at end of file