[Haskell-cafe] FGL custom node identification (Label -> Node lookup)

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Thu Nov 24 23:05:43 CET 2011

On 25 November 2011 05:13, Thomas DuBuisson <thomas.dubuisson at gmail.com> wrote:
> My thinking on this was that something akin to NodeMap should be
> _part_ of the graph structure.  This would be more convenient and
> allow the graph and nodemap operations to apply to a single data
> structure.
> Instead of:
>    insMapNode_ :: (Ord a, DynGraph g) => NodeMap a -> a -> g a b -> g a b
> You could have:
>    insMapNode_ :: (Ord a, DynGraph g) => a -> g a b -> g a b
> The only think stopping us from making a product data type like this
> is the inflexibility of the type classes, right?  Were we able to
> define (&) to update the nodemap too then we could keep these to
> structures in sync automatically instead of expecting the programmer
> to keep them paired correctly.

My thinking is to (eventually) make more fine-grained classes, and
have newtype wrappers that would add this kind of functionality (which
would even let you choose the type of constraint); i.e. adding a node
to a `(Hashable (NodeLabel g)) => HashableNodeMap g` would also add a
`NodeLabel g -> Node g` mapping to some internal lookup; is this what
you're after?

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list