-
Notifications
You must be signed in to change notification settings - Fork 140
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
Implement instance Data #614
Conversation
As |
@clyring good catch. No particular reason, just a leftover from the previous PR. Reverted now. Since there are no internal invariants to uphold, I also added |
gunfold k z c = case constrIndex c of | ||
1 -> k (z packBytes) | ||
_ -> error "gunfold: unexpected constructor of strict ByteString" | ||
dataTypeOf _ = byteStringDataType |
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.
The dataTypeOf
change affects non-throwing traces. Major version bump?
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.
PVP does not prescribe this: somewhat surprisingly, it does not say anything about term-level changes. I deem this as a bug fix, not a change of intended semantics.
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.
The intent of the existing instance implementation is not so obvious. I do think this dataTypeOf
change makes the instance more self-consistent and is an improvement.
But as a non-expert in the wider usage of Data
I'm hesitant to put even small potentially-breaking changes into a minor release. And our users seem in no particular hurry to get working gread
functionality.
The rest of the patch is fine for a minor release, of course.
PVP does not prescribe this: somewhat surprisingly, it does not say anything about term-level changes.
Right, the text of PVP mentions nothing on this subject. I'm reasonably sure that's an oversight. The graphical decision tree on the front page does have a node indicating that if "the behavior of any exported function change[d]," then a major version bump is necessary. The FAQ also provides an explicit example on this subject.
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.
I'm reasonably sure that's an oversight.
Neither FAQ nor decision tree (haskell/pvp#52) are normative. PVP is compile-time only. There was an attempt to change this (haskell/pvp#30), but it was withdrawn.
It's not a hill I want to die on, so if you feel strongly about it, I'll revert changes to dataTypeOf
.
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.
No need to revert! The change is fine; I just think this should be where bytestring-0.12
finally diverges from master
.
@clyring any more suggestions? |
* Add functionality for toConstr * Other instances fixed * Move test * test passes * Add gshow tests * Typo * Add explicit string test * instance Data: implement gunfold and dataTypeOf * instance Data: fix tests * Fix emulated builds * Restore derived instance Data ShortByteString * Add instance Generic ShortByteString * Review suggestions --------- Co-authored-by: Colton Clemmer <coltonclemmerdev@gmail.com> (cherry picked from commit 1b9e6ec)
* Add functionality for toConstr * Other instances fixed * Move test * test passes * Add gshow tests * Typo * Add explicit string test * instance Data: implement gunfold and dataTypeOf * instance Data: fix tests * Fix emulated builds * Restore derived instance Data ShortByteString * Add instance Generic ShortByteString * Review suggestions --------- Co-authored-by: Colton Clemmer <coltonclemmerdev@gmail.com> (cherry picked from commit 1b9e6ec)
* Add functionality for toConstr * Other instances fixed * Move test * test passes * Add gshow tests * Typo * Add explicit string test * instance Data: implement gunfold and dataTypeOf * instance Data: fix tests * Fix emulated builds * Restore derived instance Data ShortByteString * Add instance Generic ShortByteString * Review suggestions --------- Co-authored-by: Colton Clemmer <coltonclemmerdev@gmail.com> (cherry picked from commit 1b9e6ec)
Fixes #513.
This is #519 rebased + tweaked tests. Thanks to @cbclemmer for trailblazing.