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.
This PR adds support for most of the containers in the
containers
library. Sincecontainers
is distributed with GHC, I was hoping it wouldn't be a particularly onerous dependency. I've used this in production and it does properly handle nested structures (eq.Map a (Map b (Map c value))
). I've also included some tests to checking these implementations. The tests do included extra dependencies, but those shouldn't be needed for the base library.There's a couple of bits I can already see being issues:
I left the
Torsor
module as is an simply added my own module for the collections. It might be better to make a basicTorsor.Types
module thatTorsor.Containers
can import and haveTorsor
export both. This would remove the need to the user to explicitly importTorsor.Containers
to get the orphan container instances.I'm not great at naming things, so some of the types or function may need new names
I have intentionally not included an implementation for the list type, since diffing will always hang on an infinite list. That's also the reason that the
ContainerDiff
type uses a Seq - to enforce that the list is finite. However, using lists may be more performant for our use case. Also, lists are a fairly common data structure and I don't believe that any developer would be surprised that they couldn't find the difference between two infinte lists and would not consider this a bug.I've bumped the version number up to 0.1.1, since everything is backward compatible, but I could also understand this being version 0.2
There is no instance for
Tree
orEither
at the moment. These will hopefully come into a future PR, but they're non-trivial.