module GraphBase (
Triv,
Graph (..),
initGraph,
graphMapModify,
Node (..), newNode,
)
where
import GhcPrelude
import UniqSet
import UniqFM
type Triv k cls color
= cls
-> UniqSet k
-> UniqSet color
-> Bool
data Graph k cls color
= Graph {
Graph k cls color -> UniqFM (Node k cls color)
graphMap :: UniqFM (Node k cls color) }
initGraph :: Graph k cls color
initGraph :: Graph k cls color
initGraph
= Graph :: forall k cls color. UniqFM (Node k cls color) -> Graph k cls color
Graph
{ graphMap :: UniqFM (Node k cls color)
graphMap = UniqFM (Node k cls color)
forall elt. UniqFM elt
emptyUFM }
graphMapModify
:: (UniqFM (Node k cls color) -> UniqFM (Node k cls color))
-> Graph k cls color -> Graph k cls color
graphMapModify :: (UniqFM (Node k cls color) -> UniqFM (Node k cls color))
-> Graph k cls color -> Graph k cls color
graphMapModify UniqFM (Node k cls color) -> UniqFM (Node k cls color)
f Graph k cls color
graph
= Graph k cls color
graph { graphMap :: UniqFM (Node k cls color)
graphMap = UniqFM (Node k cls color) -> UniqFM (Node k cls color)
f (Graph k cls color -> UniqFM (Node k cls color)
forall k cls color. Graph k cls color -> UniqFM (Node k cls color)
graphMap Graph k cls color
graph) }
data Node k cls color
= Node {
Node k cls color -> k
nodeId :: k
, Node k cls color -> cls
nodeClass :: cls
, Node k cls color -> Maybe color
nodeColor :: Maybe color
, Node k cls color -> UniqSet k
nodeConflicts :: UniqSet k
, Node k cls color -> UniqSet color
nodeExclusions :: UniqSet color
, Node k cls color -> [color]
nodePreference :: [color]
, Node k cls color -> UniqSet k
nodeCoalesce :: UniqSet k }
newNode :: k -> cls -> Node k cls color
newNode :: k -> cls -> Node k cls color
newNode k
k cls
cls
= Node :: forall k cls color.
k
-> cls
-> Maybe color
-> UniqSet k
-> UniqSet color
-> [color]
-> UniqSet k
-> Node k cls color
Node
{ nodeId :: k
nodeId = k
k
, nodeClass :: cls
nodeClass = cls
cls
, nodeColor :: Maybe color
nodeColor = Maybe color
forall a. Maybe a
Nothing
, nodeConflicts :: UniqSet k
nodeConflicts = UniqSet k
forall a. UniqSet a
emptyUniqSet
, nodeExclusions :: UniqSet color
nodeExclusions = UniqSet color
forall a. UniqSet a
emptyUniqSet
, nodePreference :: [color]
nodePreference = []
, nodeCoalesce :: UniqSet k
nodeCoalesce = UniqSet k
forall a. UniqSet a
emptyUniqSet }