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.

@L0neGamer L0neGamer force-pushed the fromseta-follow-up-changes branch from 4b9f984 to 79a89bc Compare November 26, 2025 17:55
@L0neGamer
Copy link
Contributor Author

@meooow25 got around to undoing those changes. I keep my removal of IsInt in favour of Int ~. If it somehow fails the CI, then I'll revert that as well.

@treeowl
Copy link
Contributor

treeowl commented Nov 26, 2025

You seem to have done some substantial reworking of Arbitrary instances here, none of which are related to the purpose of the PR. Please don't do that. You can propose those changes (with explanations of why, and preferably some more source comments too) in a separate PR.

@L0neGamer L0neGamer force-pushed the fromseta-follow-up-changes branch from 79a89bc to 0b474aa Compare November 26, 2025 18:09
@treeowl
Copy link
Contributor

treeowl commented Nov 26, 2025

The purpose of IsInt is to support potential future Haskell compilers that don't support GHC-style type equality constraints. I believe @ekmett is among those who thinks those are a plausible future target. I suppose we could just wait for them to actually exist....

@L0neGamer
Copy link
Contributor Author

Happy to discuss IsInt on the other PR; one option is that we could use mhs in the testing pipeline as well if we do want to commit to non-ghc testing. My impression was that while the testing is ghc only, we may as well make it more readable.

@treeowl
Copy link
Contributor

treeowl commented Nov 26, 2025

The last I heard, MHS wasn't ready for QuickCheck. But maybe @augustss can give us an update.

@treeowl
Copy link
Contributor

treeowl commented Nov 26, 2025

I definitely don't think that change belongs in this pull request; it's a much better fit for the other one.

@augustss
Copy link
Contributor

Mhs can compile quickcheck, but not many of the testing frameworks. Yet.

@Bodigrim
Copy link
Contributor

Mhs can compile quickcheck, but not many of the testing frameworks. Yet.

(I'm trying to get tasty compiling with MicroHs, that's why my recent questions in MicroHs / MicroCabal repos)

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.

Thanks!

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.

5 participants