-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ToGraph
maybe doesn't need so many methods?
#151
Comments
As an example of how this can lead to some (accidental?) inconsistency, |
I'm not a big fan of
This is not accidental. I just don't know how to make it a method of the scc :: (ToGraph g, ToGraph h, ToVertex h ~ g) => g -> h Alas, this doesn't really express the fact that the inner graphs in the Summary: Here are the methods we should probably remove from @michaelpj Does this sound reasonable? |
Hm, it seems like many of these do in fact have at least the potential for more efficient implementations. I would be tempted to split out the "can be folded into a graph" class from the "overridable graph operations class" for clarity, but that's somewhat subjective and based on my confusion on first discovering the class. i.e. something like
You could even drop the
Couldn't you concretely return an |
I have a feeling that splitting off
Well, in this case I won't be able to add |
This revision addresses a few issues: * Improves the testsuite (#13) by switching to simpler graph `API` type class. * Simplifies the `ToGraph` class, as discussed in #151. * Removes `Algebra.Graph.Fold` which, while cool, appears to be useless in practice. * Removes dependencies on `base-compat` and `base-orphans`, which are no longer critical.
I understand that the intention of
ToGraph
, likeFoldable
, is that some of the methods can be overridden to provide better performance.But in practice it seems like the only ones that actually matter are
foldG
(special implementation forFold
)toGraph
,toAdjacencyMap
,toAdjacencyIntMap
(special implementations for those very types or similar ones)AFAICT the overriding implementations are all equivalent to calling the default implementations on
ToGraph
with the specialised version of e.g.toAdjacencyMap
. For example,LabelledAdjacencyMap
just delegates to theAdjacencyMap
functions after callingskeleton
... which is just its definition oftoAdjacencyMap
.So I think we could have a
ToGraph
class that just hadfoldG
and thetoX
methods, and then provide some generic implementations of the others as functions with aToGraph
constraint, rather than class methods.Is this actually a problem? Not enormously, it just looks odd to a reader to have such a profusion of class methods, which will potentially grow indefinitely as more algorithms are added.
(I might just be missing some overrides that are in fact performance-critical, of course!)
The text was updated successfully, but these errors were encountered: