Coercing a `ByteArray#` into a `MutableByteArray#`
chessai
chessai1996 at gmail.com
Mon Jul 24 18:17:15 UTC 2023
Hi Adithya,
The representations are the same. You can do this. I do this somewhat
often. Just avoid mutating in places where it could result in funky stuffs.
This is usually pretty easy to spot.
Cheers,
chessai
On Mon, Jul 24, 2023, 12:59 Adithya Kumar <adi.obilisetty at gmail.com> wrote:
> Hello all,
>
> I have a use-case where I want to convert `ByteArray#` to
> `MutableByteArray#`
> without the copy overhead.
>
> Is the underlying memory structure of `ByteArray#` and `MutableByteArray#`
> the
> same?
>
> If I can guarantee that I won't mutate my `MutableByteArray#`, can I use
> `unsafeCoerce#` on `ByteArray#` and treat it as `MutableByteArray#`?
>
> Best,
> Adithya
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20230724/1a36dd38/attachment.html>
More information about the ghc-devs
mailing list