Introduce Data.VM.Linear and Data.LArray.Mutable.Unlifted.Linear #341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aVM
type, which is ourV
on 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.Linear
is mostly a copy ofData.Array.Mutable.Unlifted.Linear
; with changes to preserve the linearity of the elements:update
function; andget
andset
functions requireDupable
andConsumable
constraints.lseq
anddup2
over arrays consumes or duplicates the elements one by one.And we have
VM
implemented as a length-indexed wrapper over theLArray
. It uses the type-level utilities from the originalV
module and provides a similarmake
andelim
functions; the main difference beingmake
function taking a linear callback.And here is the missing parts (hence this is yet a draft):
Data.Array.Mutable.Unlifted.Linear
, a separateVM
type).VM
on theDupable
class. 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.