on 2e489ea help sign in
104 lines 2.2 kB history raw
1{-# LANGUAGE CPP #-}
2-- |
3-- Module : Streamly.Data.MutArray
4-- Copyright : (c) 2022 Composewell Technologies
5--
6-- License : BSD3
7-- Maintainer : streamly@composewell.com
8-- Stability : released
9-- Portability : GHC
10--
11-- This module provides a mutable version of "Streamly.Data.Array". The
12-- contents of a mutable array can be modified in-place. For general
13-- documentation, please refer to the original module.
14--
15-- Please refer to "Streamly.Internal.Data.Array.Mut" for functions that have
16-- not yet been released.
17--
18-- For mutable arrays that work on boxed types, not requiring the 'Unbox'
19-- constraint, please refer to "Streamly.Data.MutArray.Generic".
21module Streamly.Data.MutArray
22 (
23 -- * Setup
24 -- | To execute the code examples provided in this module in ghci, please
25 -- run the following commands first.
26 --
27 -- $setup
29 -- * Mutable Array Type
30 MutArray
32 -- * Construction
34 -- Uninitialized Arrays
35 , new
36 , pinnedNew
38 -- From containers
39 , fromListN
40 , fromList
41 , writeN -- drop new
42 , write -- full buffer
43 -- writeLastN
45 -- * Appending elements
46 , snoc
48 -- * Appending streams
49 , writeAppendN -- XXX Rename to writeSnocN?
50 , writeAppend -- XXX Rename to writeSnoc?
52 -- * Inplace mutation
53 , putIndex
54 , putIndexUnsafe
55 , modifyIndex
56 , modifyIndexUnsafe
57 , modify
59 -- * Random access
60 , getIndex
61 , getIndexUnsafe
63 -- * Conversion
64 , toList
66 -- * Streams
67 , read
68 , readRev
70 -- * Unfolds
71 , reader
72 , readerRev
74 -- * Casting
75 , cast
76 , asBytes
78 -- * Size
79 , length
81 -- * Unbox Type Class
82 , Unbox (..)
84 -- * Pinning & Unpinning
85 , pin
86 , unpin
87 , isPinned
89 -- * Deprecated
90 , newPinned
91 )
92where
94import Prelude hiding (length, read)
95import Streamly.Internal.Data.Array.Mut
96import Streamly.Internal.Data.Unbox (Unbox (..))
97import Control.Monad.IO.Class (MonadIO)
99#include "DocTestDataMutArray.hs"
101{-# DEPRECATED newPinned "Please use pinnedNew instead." #-}
102{-# INLINE newPinned #-}
103newPinned :: forall m a. (MonadIO m, Unbox a) => Int -> m (MutArray a)
104newPinned = pinnedNew