Skip to content

Conversation

@jorisdral
Copy link
Contributor

@jorisdral jorisdral commented Feb 7, 2023

Precursor reference: #15 (comment)

#15 brought back unsafe constructors in the diff-containers package. A side-effect of this is that we can not hide the internals (Data.Map.Diff.Strict.Internal) behind a truly safe interface (Data.Map.Diff.Strict). Instead, downstream code now has the responsibility to use the semi-safe interface faithfully.

What it means to use diffs in a safe way is now documented in the code, amongst others using PRECONDITION, INVARIANT and POSTCONDITION annotations. This PR also introduces tests for these properties.

The invariant for downstream code to uphold is to only ever apply diffs that are both "normal" and "positive". Faithful use of the API should prevent this from happening.

The README that will be added in resolving #8 will explain both the normality and positivity properties, and it will contain examples of use cases.

@jorisdral jorisdral added the documentation Improvements or additions to documentation label Feb 7, 2023
@jorisdral jorisdral self-assigned this Feb 7, 2023
@jorisdral jorisdral added the testing Improvements or additions to tests label Feb 7, 2023
@jorisdral jorisdral force-pushed the jdral/diff-containers-test-invariants branch from 3c78927 to 65bd594 Compare February 9, 2023 12:32
* Better explain unresolved sums and subtractions.
* Better explain positivity and normality.
* Remove duplicate module documentation.
* Refactor `isNormalDiffHistory` to use `zip`.
* Preserve invariants in shrinkers.
* Be more explicit about normality/normal form.
@jorisdral
Copy link
Contributor Author

@dnadales @jasagredo I have added tests for the generators/shrinkers. While writing them, I also realised that "positivity implies normality": a positive diff or diff history is by definition also normal. So I've added a test for that as well, and the documentation now also mentions this

* Test generators
* Remove implications that are no satisfied by generators.
* New property: positivity implies normality
@jorisdral jorisdral force-pushed the jdral/diff-containers-test-invariants branch from 7d59dff to 47aaf2b Compare February 10, 2023 09:52
Copy link

@dnadales dnadales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'm really happy with the tests for the generators

@jorisdral jorisdral merged commit 25ea38d into main Feb 14, 2023
@jorisdral jorisdral deleted the jdral/diff-containers-test-invariants branch February 14, 2023 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation testing Improvements or additions to tests

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants