Add isByteArrayCompactable# operation
This feature is motivated by https://www.reddit.com/r/haskell/comments/102ofst/why_cant_bytearray_be_put_in_a_compact_region/ discussion.
ByteArray#
can be unpinned or pinned. Unpinned ByteArray#
can be compacted, but for pinned arrays as told by isByteArrayPinned#
you cannot know.
This is somewhat relevant to ShortByteString
type in bytestring
. It tells to be pinned, while more correct would be to say "is created with newByteArray#
not newPinnedByteArray#
", i.e. "compactable". The isByteArrayCompactable#
would allow to check the invariant (one can do that by trying to compact the ByteArray#
value, but that is indirect and in IO).
I'm not sure whether compactable is the best adjective do describe this property, but I don't know if there are any other than compacting use cases which depend on it.
EDIT: E.g. docs for resizeMutableByteArray#
talk about unpinned bytearray#, but I guess they mean "created with newByteArray#
as well.
cc bytestring
maintainer @Bodigrim.