module GHC.Data.Graph.Base (
Triv,
Graph (..),
initGraph,
graphMapModify,
Node (..), newNode,
)
where
import GHC.Prelude
import GHC.Types.Unique.Set
import GHC.Types.Unique.FM
type Triv k cls color
= cls
-> UniqSet k
-> UniqSet color
-> Bool
newtype Graph k cls color
= Graph {
forall k cls color.
Graph k cls color -> UniqFM k (Node k cls color)
graphMap :: UniqFM k (Node k cls color) }
initGraph :: Graph k cls color
initGraph :: forall k cls color. Graph k cls color
initGraph
= Graph
{ graphMap :: UniqFM k (Node k cls color)
graphMap = UniqFM k (Node k cls color)
forall {k} (key :: k) elt. UniqFM key elt
emptyUFM }
graphMapModify
:: (UniqFM k (Node k cls color) -> UniqFM k (Node k cls color))
-> Graph k cls color -> Graph k cls color
graphMapModify :: forall k cls color.
(UniqFM k (Node k cls color) -> UniqFM k (Node k cls color))
-> Graph k cls color -> Graph k cls color
graphMapModify UniqFM k (Node k cls color) -> UniqFM k (Node k cls color)
f Graph k cls color
graph
= Graph k cls color
graph { graphMap = f (graphMap graph) }
data Node k cls color
= Node {
forall k cls color. Node k cls color -> k
nodeId :: k
, forall k cls color. Node k cls color -> cls
nodeClass :: cls
, forall k cls color. Node k cls color -> Maybe color
nodeColor :: Maybe color
, forall k cls color. Node k cls color -> UniqSet k
nodeConflicts :: UniqSet k
, forall k cls color. Node k cls color -> UniqSet color
nodeExclusions :: UniqSet color
, forall k cls color. Node k cls color -> [color]
nodePreference :: [color]
, forall k cls color. Node k cls color -> UniqSet k
nodeCoalesce :: UniqSet k }
newNode :: k -> cls -> Node k cls color
newNode :: forall k cls color. k -> cls -> Node k cls color
newNode k
k cls
cls
= 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 }