Skip to content

Conversation

@L0neGamer
Copy link
Contributor

Finally getting to some of the changes requested by @meooow25 on #1163

In this PR we remove some unused instances, and try and share the implementations for some other instances. We also do some cleanup for some of the testing code. We use liftA3 instead of manually combining three actions (which uses liftA2 in the default implementation), and we also verify that the result of fromSetA is correct in the case of the action ordering property test.

@L0neGamer L0neGamer force-pushed the fromseta-follow-up-changes branch from dbf6ed1 to bff17cf Compare November 16, 2025 19:00
@treeowl treeowl changed the title Fromseta follow up changes fromSetA follow up changes Nov 16, 2025
@treeowl
Copy link
Contributor

treeowl commented Nov 16, 2025

Both fromSet and fromSetA seem to be missing validity (i.e., data structure invariant) tests. I don't understand your (partial?) collection of Arbitrary instances, or why that's in this PR.

@L0neGamer
Copy link
Contributor Author

I would appreciate guidance on what to look for for data structure invariant tests.

I moved those arbitrary instances to a separate module because, at least for the Set one, the instance was needlessly duplicated across modules and had increased complexity for no reason. If there was some shared containers-testing lib, then this module could be compiled once for all testing executables, but that is not the case currently.

I would've moved the Map ones as well but of course the strict and lazy variants would have to have the odd cpp-based substitution, and that was complexity I wanted to avoid.

@treeowl
Copy link
Contributor

treeowl commented Nov 16, 2025

Understood. The function you're looking for is called valid. For largely hysterical raisins, it's actually exposed from Data.Set. (In modern Haskell library design, there'd probably be a separate Unsafe module for functions that can break the invariants, and we'd probably expose the functions for diagnosing said breakage there.)

Copy link
Contributor

@treeowl treeowl left a comment

Choose a reason for hiding this comment

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

I'm generally okay with this. Do you intend to reorganize the other Arbitrary instances in a follow-up?

@L0neGamer
Copy link
Contributor Author

I can if wanted but I don't think it would be the cleanest solution.

Since this was triggered by @meooow25's request, I ask that they approve as well before merging.

Copy link
Contributor

@meooow25 meooow25 left a comment

Choose a reason for hiding this comment

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

Looks good to remove the Bot instances, improve the tests, and use liftA3.

But I also don't think the other Arbitrary changes belong here.
IMO there is no benefit in touching those instances at all. That little bit of duplication is harmless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants