X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Data%2FHList%2FGraph.hs;h=7a833ea4ec2e10eadbf9345f1ff575825610a750;hb=000307857df5266907964aff4ecc9e118314fe3f;hp=ee5f613f1d5b4daea8ff4ed47dad0d643d31bb54;hpb=c788edcf6744a51cb38795e4f1959d22d10ad071;p=hs-rrdtool.git diff --git a/Data/HList/Graph.hs b/Data/HList/Graph.hs index ee5f613..7a833ea 100644 --- a/Data/HList/Graph.hs +++ b/Data/HList/Graph.hs @@ -1,33 +1,59 @@ {-# LANGUAGE + EmptyDataDecls, FlexibleContexts, FlexibleInstances, + MultiParamTypeClasses, TypeFamilies #-} module Data.HList.Graph - ( HNodeSet - , HNode(..) - , HGraph(..) + ( Graph(..) + , NodeSet + , NodeIDSet + , Node(..) + , LPath(..) + + , IsEmpty + + , NodeIDA ) where import Data.HList.Prelude --- HNodeSet -class HNodeSet ns -instance HNodeSet HNil -instance HNodeSet ns => HNodeSet (HCons n ns) +-- NodeSet +class NodeSet ns +instance NodeSet Nil +instance NodeSet ns => NodeSet (Cons n ns) --- HNode -class ( HNodeSet (HLinksFrom n) - ) - => HNode n +-- 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 + +-- NodeIDA +data NodeIDA +instance ApplyT NodeIDA n where + type Apply NodeIDA n = NodeID n --- HGraph -class ( HNodeSet (HNodes g) +-- 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