<div dir="auto"><div>Indeed, this is what the `primitive` package provides to thaw a `ByteArray#` without copying:</div><div dir="auto"><br></div><div dir="auto"><a href="https://hackage.haskell.org/package/primitive-0.8.0.0/docs/src/Data.Primitive.ByteArray.html#unsafeThawByteArray">https://hackage.haskell.org/package/primitive-0.8.0.0/docs/src/Data.Primitive.ByteArray.html#unsafeThawByteArray</a><br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Mon, 24 Jul 2023, 20:17 chessai, <<a href="mailto:chessai1996@gmail.com">chessai1996@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Hi Adithya,<div dir="auto"><br></div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">Cheers,</div><div dir="auto">chessai</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 24, 2023, 12:59 Adithya Kumar <<a href="mailto:adi.obilisetty@gmail.com" target="_blank" rel="noreferrer">adi.obilisetty@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello all,<br><br>I have a use-case where I want to convert `ByteArray#` to `MutableByteArray#`<br>without the copy overhead.<br><br>Is the underlying memory structure of `ByteArray#` and `MutableByteArray#` the<br>same?<br><br>If I can guarantee that I won't mutate my `MutableByteArray#`, can I use<br>`unsafeCoerce#` on `ByteArray#` and treat it as `MutableByteArray#`?<br><br>Best,<br>Adithya<br></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" rel="noreferrer noreferrer" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div></div></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank" rel="noreferrer">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div></div></div>