Ticket #65 (new enhancement)

Opened 19 months ago

Last modified 14 months ago

Provide a invidual-item update action in mutable vector API

Reported by: hvr Owned by:
Priority: minor Milestone: 0.10
Version: Keywords:
Cc: alexey.skladnoy@…

Description

One of the operations I've caught myself defining is an update action for modifying an invididual item in a vector, i.e.:

import qualified Data.Vector.Unboxed.Mutable as VUM

update vec idx op = VUM.write vec idx . op =<< VUM.read vec idx

Could such a convenience operation (unless it's already there) be added to the mutable vector APIs?

Change History

Changed 16 months ago by rl

  • milestone set to 0.10

Changed 14 months ago by Khudyakov

  • cc alexey.skladnoy@… added

I wanted such function all the time too. Maybe modify is better name since it's used by state monad in transformers/mtl

There is possible lazyness related pitfall. If vector's elements aren't forced modify may build huge chain of thunks. So variant which evaluates result of function evaluation to WHNF could be useful too.

Note: See TracTickets for help on using tickets.