Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NonZero #4837

Merged
merged 2 commits into from
Jan 28, 2025
Merged

Added NonZero #4837

merged 2 commits into from
Jan 28, 2025

Conversation

Soupstraw
Copy link
Contributor

@Soupstraw Soupstraw commented Jan 15, 2025

Description

This PR adds the NonZero module and gets rid of unsafe division (or at least makes the error explicit).

closes #4696

Checklist

  • Commits in meaningful sequence and with useful messages
  • Tests added or updated when needed
  • CHANGELOG.md files updated for packages with externally visible changes

    New section is never added with the code changes. (See RELEASING.md)
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary

    If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • Code formatted (use scripts/fourmolize.sh)
  • Cabal files formatted (use scripts/cabal-format.sh)
  • hie.yaml updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@Soupstraw Soupstraw force-pushed the jj/safe-division branch 17 times, most recently from 48b1e81 to 930bddd Compare January 17, 2025 12:55
@Soupstraw Soupstraw marked this pull request as ready for review January 17, 2025 13:03
@Soupstraw Soupstraw requested a review from a team as a code owner January 17, 2025 13:03
@Soupstraw Soupstraw force-pushed the jj/safe-division branch 3 times, most recently from f0f71ea to 98ad7eb Compare January 17, 2025 15:44
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

I understand you have good intentions, but this PR instead of introducing a simplification, as was intended by #4696, makes all those places where %? was suppose to be used even more complicated.
Please, go through my suggestions and I'll review the PR again.

Don't get me wrong, I really do like the NonZero interface that you implemented in this PR, except this interface needs to be used only in places where we can guarantee a non zero value! securityParameter is a perfect example of such use case, because we can guarantee that it is non-zero. NOpt will be another, but only once we change its serialization, not before.

@Soupstraw Soupstraw force-pushed the jj/safe-division branch 7 times, most recently from 822132f to 043541c Compare January 20, 2025 16:32
@Soupstraw Soupstraw force-pushed the jj/safe-division branch 3 times, most recently from 3c5c104 to ce1ba92 Compare January 22, 2025 12:27
@Soupstraw Soupstraw force-pushed the jj/safe-division branch 7 times, most recently from bd85ba2 to b6921de Compare January 23, 2025 13:16
@Soupstraw Soupstraw requested a review from lehins January 23, 2025 13:19
@Soupstraw Soupstraw force-pushed the jj/safe-division branch 6 times, most recently from 07943f2 to db675aa Compare January 23, 2025 14:05
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

Beautiful!
Thank you!

eras/shelley/impl/src/Cardano/Ledger/Shelley/PoolRank.hs Outdated Show resolved Hide resolved
eras/shelley/impl/src/Cardano/Ledger/Shelley/PoolRank.hs Outdated Show resolved Hide resolved
eras/shelley/impl/src/Cardano/Ledger/Shelley/PoolRank.hs Outdated Show resolved Hide resolved
@Soupstraw Soupstraw force-pushed the jj/safe-division branch 3 times, most recently from e314307 to d5da0c7 Compare January 27, 2025 11:18
Co-authored-by: Alexey Kuleshevich <alexey.kuleshevich@iohk.io>
@Soupstraw Soupstraw force-pushed the jj/safe-division branch 3 times, most recently from 93f203d to ffc46e9 Compare January 27, 2025 12:03
@lehins lehins merged commit 85543d6 into master Jan 28, 2025
153 of 156 checks passed
@lehins lehins deleted the jj/safe-division branch January 28, 2025 00:26
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.

Add %? operator
2 participants