Introduce Data.VM.Linear and Data.LArray.Mutable.Unlifted.Linear#341
Introduce Data.VM.Linear and Data.LArray.Mutable.Unlifted.Linear#341
Conversation
What would be the type of |
Very good point; it can not be For a similar reason, something like a What do you think? |
|
I think that it still makes sense to add Could you tell me what does |
Agreed. I do believe Arrays containing linear elements are useful, but it was unfortunate that we couldn't express this polymorphically, instead resorted to completely new types. That's why I was hopeful with the new Anyhow, I'll leave this to your discretion, feel free to close it if there's no strong need :). |
|
I'm not a user of However, I think that LArray.fromReplicator :: Int -> Replicator a %1 -> LArray a
LArray.fill :: Dupable a => Int -> a %1 -> -> LArray a
LArray.fill n = fromReplicator n . dupRthat we couldn't write for Anyway, I think that it would be interesting to add some Array-like memo/2-axis table to #376 #368 |
Relevant #312 .
This PR introduces a new mutable linear array type called
LArray(Data.LArray.Mutable.Unlifted.Linear), which contains linear elements. And it uses that to implement aVMtype, which is ourVon a mutable backing store.There're many design decisions, so I decided to create a draft PR before working more on this.
The new
Data.LArray.Mutable.Unlifted.Linearis mostly a copy ofData.Array.Mutable.Unlifted.Linear; with changes to preserve the linearity of the elements:updatefunction; andgetandsetfunctions requireDupableandConsumableconstraints.lseqanddup2over arrays consumes or duplicates the elements one by one.And we have
VMimplemented as a length-indexed wrapper over theLArray. It uses the type-level utilities from the originalVmodule and provides a similarmakeandelimfunctions; the main difference beingmakefunction taking a linear callback.And here is the missing parts (hence this is yet a draft):
Data.Array.Mutable.Unlifted.Linear, a separateVMtype).VMon theDupableclass. I feel like it would be a good default (based on Using a mutable backing store (such as Array) for V #312), but we have to have an efficient Applicative instance.