You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Contiguous to implement a new immutable HAMT-style hashmap.
As part of this, I want to provide an unsafeInsert (which is a building block to make other construction functions, like fromList fast).
This, in turn, is built upon unsafeThaw, to mutate the existing immutable arrays in place.
unsafeThaw is supported by the various arrays Contiguous is wrapping, but not yet part of the class.
Would a PR adding it be accepted?
The text was updated successfully, but these errors were encountered:
Although unsafeThaw exists as a primop in GHC, it is extremely dangerous. I've only ever seen it used in unordered-containers to help write fromList, and even there, I'm skeptical of its soundness.
It's not possibly to make fromList faster by mutating an immutable array. The existing implementation mutates a mutable array and then freezes it (in place) at the end. Can you describe something in more detail that would benefit from unsafeThaw? Maybe you do have a way to use unsafeInsert to make a faster fromList, but I am not able to see how it could possibly help.
Sorry, I just realized that I missed the first sentence that you wrote. I assume that you're copying the design of unordered-containers. I'll take a PR for unsafeThaw. I think it should only be available for ContiguousU types though, not all Countiguous types.
I am using
Contiguous
to implement a new immutable HAMT-style hashmap.As part of this, I want to provide an
unsafeInsert
(which is a building block to make other construction functions, likefromList
fast).This, in turn, is built upon
unsafeThaw
, to mutate the existing immutable arrays in place.unsafeThaw
is supported by the various arraysContiguous
is wrapping, but not yet part of the class.Would a PR adding it be accepted?
The text was updated successfully, but these errors were encountered: