-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Is your feature request related to a problem? Please describe.
dupV
can produce V n a
values efficiently for many types.
This privileges this over other possible linear storage solutions for bulk copied data.
I was hoping to work with an API that takes a V n a
and uses reflection to package it up as a Range
of values you can access that shares a common backing store. Ranges themselves are mostly type level constructs, the "real" Vector Any
gets held by reflection in common, thus ensuring never shall two values of type Range s i j _
will exist at the same time, letting you work on privately owned data, and two adjacent ranges with the same s
can be safely re-merged.
One advantage of this over just working with V n a
s is that I can split work up into sections, worksteal and reassemble my answers safely if the ranges show up in the types, and the original backing store identity is captured in a region parameter.
claim
:: forall n a b. V n a %1
-> (forall s. (KnownV s, VLength s ~ n) => Range s 0 n a %1 -> Ur b) %1
-> Ur b
merge :: forall s i j k a. Range s i j a %1 -> Range s j k a %1 -> Range s i k a
split ::: ...
declaim :: forall s i j a. KnownV s => Range s i j a %1 -> V (j - i) a
which all works great, right up until realize you can't write Linear.Functor
, or lenses to the individual members of the range, because unlike an Array, the contents of V n
aren't actually mutable.
Describe the solution you'd like
I'd like to look under the hood of V
and see something that is either a Array#
or MVector
, so that lenses to modify the ith member can be written, that don't require complete copies, and linear fmap can be implemented in place.
Describe alternatives you've considered
One thought was to use unsafe thaw operations but there isn't a strong guarantee that the vector you have is the only one using its backing array, and freezing it on one and having another segment of it thinking it was thawed on the other would be bad from a GC perspective as I understand things. moving things to a fresh mutable vector on claim
above, also seems needless and painful.