-
Notifications
You must be signed in to change notification settings - Fork 47
Add newtype wrappers around IPv4 and IPv6 #608
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
Conversation
lehins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to export conversion functions that allows to wrap with forcing and unwrap the underlying types:
wrapIPv4 :: IP.IPv4 -> IPv4
wrapIPv4 = IPv4
unwrapIPv4 :: IPv4 -> IP.IPv4
unwrapIPv4 = unIPv4
wrapIPv6 :: IP.IPv6 -> IPv6
wrapIPv6 ipv6 =
case IP.toIPv6w ipv6 of
(!w1, !w2, !w3, !w4) -> IPv6 ipv6
unwrapIPv6 :: IPv6 -> IP.IPv6
unwrapIPv6 = unIPv6If we did that, then this would be the new implementation of toIPv6w:
toIPv6w :: (Word32, Word32, Word32, Word32) -> IPv6
toIPv6w = wrapIPv6 . IP.toIPv6wInstead of wrap prefix we could use mk or something else entirely, I don't have any strong preference about it.
We also need to add FromCBOR and ToCBOR instances for those two new types to the cardano-binary.
|
This should be good for another look |
neilmayhew
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Just a few minor suggestions.
neilmayhew
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
|
Feel free to resolve my comments while I'm away |
lehins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful!
Thank you!
Description
Fix #607
Checklist
CHANGELOG.mdfor the affected packages.New section is never added with the code changes. (See RELEASING.md)
.cabalandCHANGELOG.mdfiles according to theversioning process.
.cabalfiles for all affected packages are updated.If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)