我有一个关于 Haskell 的小问题。如果我有代表这样一个图表的数据类型:
import Data.Map (Map,empty,member,insert)
import Graphviz
-- | A directed graph
data Graph v = Graph
{ arcsMap :: Map v [v] -- A map associating a vertex with its
successors
, labelMap :: Map v String -- The Graphviz label of each node
, styleMap :: Map v String -- The Graphviz style of each node
}
我想通过访问给定图形的每个顶点来创建一个列表。
像这样:
-- | Returns the list of vertices of a graph in ascending order
--
-- >>> vertices emptyGraph
-- []
-- >>> vertices $ addVertices emptyGraph [1,4,5,2,1]
-- [1,2,4,5]
vertices :: Graph v -> [v]
我的问题是如何告诉 Haskell 查看 arcsMap 中的每个顶点并用它创建一个列表?谢谢 !!!