Add unsafeThaw to Data.Array.ST?
hdgarrood opened this issue · 3 comments
I would like to be able to create an array using one of the existing functions for immutable arrays (e.g. range), and then use it locally within a function, but not return a reference to it. I would also like to be able to do this with a minimum of copying. Currently I think the best I can do is to use thaw or withArray, which make a copy of it; if I know that no references to my array can escape I should be able to get away without copying it. Could we possibly add an unsafeThaw, which has the same type as thaw but just returns a reference to the same array instead of copying?
👍 Sounds good to me.
Going to make a PR for this since nobody has done it, but I think it would also be nice to have PRs to implement the immutable array functions for ST arrays, even if internally they just use unsafeThaw. Any thoughts on this approach? I could make a separate issue for it.