-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce Data.VM.Linear and Data.LArray.Mutable.Unlifted.Linear #341
base: master
Are you sure you want to change the base?
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 . dupR that 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 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.