-
Notifications
You must be signed in to change notification settings - Fork 140
Description
This is a proposal and hasn't been set in stone yet. Please feel free to comment your opinion on the matter in this ticket.
Prelude: It has been requested many times that we provide access to all constructors from vector package. Giving access to those constructors allows violation of many invariants and hence is unsafe. Quote from #357:
Decide what is best way to expose constructors for vectors. It have been requested numerous times: #245, #343, #171, #63 (tangentially related), #49. It's of course totally unsafe. Still it's very useful to have on occasion
The best approach to tackle this is to create special Unsafe modules and export such constructors form there. This also spawned a discussion that it would make sense to migrate all of the of the unsafe functions to such modules (eg. unsafeIndex, unsafeRead, etc.), in order to provide a clear boundary between safe and dangerous functionality, which can have different qualified imports in the user land.
Doing such migration of unsafe functionality is worthwhile in a long run, but immediate problem is that it will cause a lot of breakage. Therefore it would have to be done in a few stages across couple of major releases.
- Next minor release
vector-0.12.2.0would be adding these modules with all of the unsafe functions exported from there:
module Data.Vector.Unsafe
module Data.Vector.Generic.Unsafe
module Data.Vector.Primitive.Unsafe
module Data.Vector.Storable.Unsafe
module Data.Vector.Unboxed.Unsafe- Next major release
vector-0.13, would continue to export all unsafe function from the Unsafe modules and their current locations, but latter ones would getDEPRECATEDpragma added to them. This way such change will be visible to all the users - The following major release
vector-0.14would have those unsafe functions removed from their current locations, but only if such release happens at least a year aftervector-0.13that deprecated unsafe functions.
Other relevant points to discuss:
- Do we stretch out the deprecation timeline over a longer period of time (eg. announce in vector-0.13, deprecated in vector-0.14 and remove in vector-0.15) It will take a couple of years.
- Do we also provide Unsafe modules for Bundle?
- Do we have separate Unsafe modules for Mutable vs immutable. My opinion is that such separation is not needed, since there aren't any name clashes of top of my head. And if there are any they can be mitigated by renaming, since this change is additive.
- Should we bother with monomorphic unsafe exports or instead only export
Genericunsafe functions? - Is the whole thing really worth it?