@@ -635,10 +635,20 @@ modifyIndices = undefined
635635
636636-- | Modify each element of an array using the supplied modifier function.
637637--
638−-- /Unimplemented/
639−modify :: -- forall m a b. (MonadIO m, Storable a) =>
640− Array a -> (a -> a) -> m ()
641−modify = undefined
638+-- /Pre-release/
639+modify :: forall m a. (MonadIO m, Storable a)
640+ => Array a -> (a -> a) -> m ()
641+modify Array{..} f = liftIO $
642+ unsafeWithArrayContents arrContents arrStart go
643+
644+ where
645+
646+ go ptr = do
647+ let elemSize = sizeOf (undefined :: a)
648+ when (ptr `plusPtr` elemSize <= aEnd) $ do
649+ r <- peek ptr
650+ poke ptr (f r)
651+ go (ptr `plusPtr` elemSize)
642652
643653-- | Swap the elements at two indices.
644654--