-
Notifications
You must be signed in to change notification settings - Fork 98
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
Explicit numeric conversions #1624
base: master
Are you sure you want to change the base?
Conversation
It's a big improvement, making all these casts explicit. I bet there are also some readability wins to be had by scanning the
->
|
@edmundnoble What prompted this work? |
@jwiegley A bad numeric conversion caused the catchup issue from 2.17.1, fixed in #1571. A function used to produce cuts for nodes that were catching up started to take a |
Would it be better to have separate newtypes for block heights and cut heights? |
We do, they just... Both have Num instances. Maybe we can remove those? That could also help, we do use them a lot though. |
How often do we need to transparently use them as "numbers"? What if we removed those instances and made the conversions explicit? |
That is a possibility too. But it will be more verbose. For example we frequently convert though between ( |
This PR just adds type applications to uses of
int
, which is our alias tofromIntegral
. Before merge, I recommend that we audit these conversions to make sure they're correct (especially correct w.r.t dimensions) and safe. An expansion to this would be using witch or something similar (perhaps vendored) to check that conversions are safe.