4-- Module : Streamly.Internal.Data.Array.Foreign.Mut
5-- Copyright : (c) 2020 Composewell Technologies
6-- License : BSD-3-Clause
7-- Maintainer : streamly@composewell.com
8-- Stability : experimental
11module Streamly.Internal.Data.Array.Foreign.Mut
14 -- , writeFrom -- start writing at the given position
16 -- , writeTo -- write from beginning up to the given position
21 -- , writeChunksOfFrom
30import Control.Monad.IO.Class (MonadIO(..))
31import Foreign.Storable (Storable(..))
32import Streamly.Internal.BaseCompat (unsafeWithForeignPtr)
34import Prelude hiding (length)
35import Streamly.Internal.Data.Array.Foreign.Mut.Type
37-- | /O(1)/ Write the given element at the given index in the array.
38-- Performs in-place mutation of the array.
41{-# INLINE writeIndex #-}
42writeIndex :: (MonadIO m, Storable a) => Array a -> Int -> a -> m ()
43writeIndex arr i a = do
44 let maxIndex = length arr - 1
46 then error "writeIndex: negative array index"
48 then error $ "writeIndex: specified array index " ++ show i
49 ++ " is beyond the maximum index " ++ show maxIndex
51 liftIO $ unsafeWithForeignPtr (aStart arr) $ \p ->
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list