Implement a graph with garbage collection #267
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This pull request implements a type
GraphGC
that represents a graph whose vertices are subject to garbage collection.Eventually, we will use
GraphGC
to represent a network ofPulse
: The vertices arePulse
, and the edges between them are dependencies. The functionwalkSuccessors
allows us to walk thePulse
in dependency order — with early exit (Stop
), but still with the guarantee that no vertex will be visited before its dependencies.Comments
Graph
to tests theGraphGC
against (In fact, we use it for most of the implementation as well, except for the actual garbage collection). We implement an ordinary functioncollectGarbage
on the pure graph and use QuickCheck to test that real garbage collection produces the same results.GraphGC
, one has to callremoveGarbage
explicitly — this makes it easier to reason about which vertices are in the graph, because we no longer have to deal with the concurrency of garbage collection.Graph
data type in the implementation ofGraphGC
also has the advantage that the correctness ofwalkSuccessors
can be checked on the pure data type.