Add map function for byte arrays#6
Merged
jappeace merged 1 commit intojappeace:masterfrom Mar 27, 2026
Merged
Conversation
Add `map :: (ByteArrayAccess ba, ByteArray ba) => (Word8 -> Word8) -> ba -> ba` to Data.ByteArray.Methods, which applies a function to each byte of a byte array. Uses copyAndFreeze to copy the array then modify each byte in-place. Bump version to 0.22.0. QuickCheck property test verifies equivalence with Prelude.map on unpacked bytes. Prompt: implement this issue for ram: jappeace#5 find a good place to put it into jappeace/ram bump the version, write a test to verify it works too Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
@kazu-yamamoto please review if this is what you want ^ |
|
LGTM. Since this is just an addition, I initially thought the version should be 0.21.2. However, the name I will probably ask two more additions. |
|
Making |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
map :: (ByteArrayAccess ba, ByteArray ba) => (Word8 -> Word8) -> ba -> batoData.ByteArray.Methods(re-exported viaData.ByteArray), as requested in map #5copyAndFreezeto copy the array then mutate each byte in-placeB.map f == B.pack . Prelude.map f . B.unpackCloses #5
Test plan
cabal buildpasses with no new warningscabal test— all 278 tests pass (including newmaptest for bothBytesandScrubbedBytesbackends)nix-build nix/ci.nixsucceedsB.mapnot in scope)🤖 Generated with Claude Code