{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreigh5ubj53ljqgu5bpw7t5oaquvthdsiiztualw42nugcmtfzo6f3e",
    "uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mpjecdy3l362"
  },
  "path": "/t/clc-proposals-rfc/14334#post_2",
  "publishedAt": "2026-06-30T14:43:36.000Z",
  "site": "https://discourse.haskell.org",
  "tags": [
    "github.com/haskell/core-libraries-committee",
    "Extend ByteArray resizing functions",
    "L0neGamer"
  ],
  "textContent": "github.com/haskell/core-libraries-committee\n\n####  Extend ByteArray resizing functions\n\nopened 12:21PM - 20 Jun 26 UTC\n\n\n\n          L0neGamer\n        \n\nThe operator to resize mutable bytearrays ([resizeMutableByteArray#](https://hac…kage-content.haskell.org/package/base-4.22.0.0/docs/GHC-Base.html#v:resizeMutableByteArray-35-)) currently states that it will attempt to resize the mutable byte array in place, and if it cannot do that it will allocate an unpinned byte array to copy into. _note: In this proposal, we will refer to only arrays that have been explicitly pinned (with `newPinnedByteArray#` or `newAlignedPinnedByteArray#`); pinning from being large or in a compact region isn't relevant here_ This proposals suggests that we add the following primops to `GHC(.Internal)?.Base` to allow the programmer to more explicitly control the pinnedness of the resultant mutable byte array when in-place resizing cannot take place: - `resizeMutableByteArrayKeepPinned#` - make the copy-into array the same pinnedness as the input array - `resizeMutableByteArrayPreferPinned#` - make the copy-into array pinned - `resizeMutableByteArrayPreferUnpinned#` - make the copy-into array unpinned Additionally, `resizeMutableByteArray#` will be defined as `resizeMutableByteArray# = resizeMutableByteArrayPreferUnpinned#`. This allows developers the greatest control possible over the mutable byte arrays they use, reducing the checks that they would need to do to check if an array they have is pinned or not. ### Alternatives - change resizeMutableByteArray# to maintain pinnedness (since it does not guarantee which pinnedness it uses, this is like saying \"it's a coin flip\" and then only landing on heads). - use a function that takes an enum/int to determine behavior instead of three new functions ### Additional notes GHC MR: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/16010 GHC Issue: https://gitlab.haskell.org/ghc/ghc/-/issues/27244 GHC User Guide Pinned ByteArrays: https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/ffi.html#pinned-byte-arrays",
  "title": "CLC proposals RFC"
}