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

Switch Data.ByteString.Short to ByteArray #410

Merged
merged 4 commits into from
Oct 9, 2022

Conversation

Bodigrim
Copy link
Contributor

@Bodigrim Bodigrim commented Aug 7, 2021

sjakobi
sjakobi previously approved these changes Aug 10, 2021
Copy link
Member

@sjakobi sjakobi left a comment

Choose a reason for hiding this comment

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

LGTM! :)

@Bodigrim
Copy link
Contributor Author

Ideally I would like to have type ShortByteString = ByteArray instead of newtype ShortByteString = ShortByteString ByteArray, but instance Ord is an obstacle. ByteArray first compares lengths, while ShortByteString uses lexicographic ordering. And if we change instance Ord ShortByteString to compare lengths first in, say, bytestring-0.12, it will become awkwardly incompatible with instance Ord ByteString.

@clyring
Copy link
Member

clyring commented Nov 25, 2021

The Semigroup instance is rather unsavory as well, as it appears obviously memory-unsafe in the presence of Int overflow.

@Bodigrim
Copy link
Contributor Author

Since we are stuck with a newtype we do not win anything from reusing instances of ByteArray - we still need to retain old implementations for not-so-bleeding-edge GHCs. Let's scale back changes and stick to our existing instances and revisit this question in bytestring-0.12.

@Bodigrim Bodigrim marked this pull request as ready for review November 26, 2021 21:55
@Bodigrim
Copy link
Contributor Author

@sjakobi could you please take another look? Is it suitable for bytestring-0.11 series?

Copy link
Member

@sjakobi sjakobi 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 not sure yet whether this can be done without a breaking change. I think the main problem is that the ShortByteString constructor is (and has been) exported.

It seems that the derived Typeable instance will also change, and depend on the base version. :/

Also, could you clarify what the motivation for this change is? That should help document this change.

For clarity, I'll remove my old approval for now.

Data/ByteString/Short.hs Outdated Show resolved Hide resolved
Data/ByteString/Short/Internal.hs Outdated Show resolved Hide resolved
@sjakobi sjakobi dismissed their stale review November 27, 2021 05:12

Compatibility woes, various questions

@sjakobi sjakobi marked this pull request as draft December 4, 2021 01:47
@sjakobi
Copy link
Member

sjakobi commented Dec 4, 2021

I've marked this as a draft for now. Feel free to mark it ready of review once it's ready for another round of review.

Copy link
Member

@clyring clyring left a comment

Choose a reason for hiding this comment

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

Incidentally, I fixed the overflow issues in ByteArray's Semigroup instance upstream, though that patch has not been backported to 9.4. So that earlier concern of mine is less relevant now.

Data/ByteString/Short/Internal.hs Outdated Show resolved Hide resolved
Data/ByteString/Short.hs Outdated Show resolved Hide resolved
Data/ByteString/Short/Internal.hs Show resolved Hide resolved
Copy link
Member

@sjakobi sjakobi left a comment

Choose a reason for hiding this comment

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

Nice solution with the compat package! :)

Data/ByteString/Short/Internal.hs Outdated Show resolved Hide resolved
Data/ByteString/Short/Internal.hs Show resolved Hide resolved
Data/ByteString/Short/Internal.hs Show resolved Hide resolved
Copy link
Member

@sjakobi sjakobi left a comment

Choose a reason for hiding this comment

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

👍

@hasufell
Copy link
Member

hasufell commented Oct 8, 2022

Benchmark results?

@Bodigrim
Copy link
Contributor Author

Bodigrim commented Oct 8, 2022

@hasufell no measurable difference, as expected.

@hasufell
Copy link
Member

hasufell commented Oct 8, 2022

@hasufell no measurable difference, as expected.

Indeed, although I did not expect it.

@Bodigrim
Copy link
Contributor Author

Bodigrim commented Oct 8, 2022

The CI is finally green, including 32-bit build. If there are no further suggestions, I'll merge by the end of weekend.

@Bodigrim Bodigrim merged commit 91a727c into haskell:master Oct 9, 2022
@Bodigrim Bodigrim deleted the bytearray branch October 9, 2022 21:28
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