-
Notifications
You must be signed in to change notification settings - Fork 73
Description
I was looking into using this library (and the Algebra.Graph.Labelled.AdjacencyMap module in particular), but the edge type I want to use is not a Monoid, only a Semigroup. Indeed, one of the things I like about Labelled.AdjacencyMap is that the adjacencies are stored sparsely, i.e., that non-existent edges are not stored, which makes a lot of sense for me because there is no value in my edge type that represents not-an-edge.
If I'm understanding the code correctly, it looks like mempty (or zero) of the edge monoid is only used to filter zero edges out of the adjacency map. I'm not proposing you drop the Monoid constraint -- for edge types that do have a zero element, filtering it out makes sense -- but it seems to me there could be a parallel module for labeled adjacency maps that only uses a Semigroup constraint and never filters.
P.S. Also, I understand that I could wrap my edge type in Maybe and, because the labeled AdjacencyMap never stores zero edges, unwrap with something like fromJust every time I view an edge. I find this unsatisfying.