on master help sign in
110 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.MutArray" 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 , emptyOf
36 , pinnedEmptyOf
38 -- From containers
39 , fromListN
40 , fromList
41 , createOf
42 , create
43 -- writeLastN
45 -- * Pinning & Unpinning
46 , pin
47 , unpin
48 , isPinned
50 -- * Appending elements
51 , snoc
53 -- * Appending streams
54 , appendN
55 , append
57 -- * Inplace mutation
58 , putIndex
59 , putIndexUnsafe
60 , modifyIndex
61 , modifyIndexUnsafe
62 , modify
64 -- * Random access
65 , getIndex
66 , getIndexUnsafe
68 -- * Conversion
69 , toList
71 -- * Streams
72 , read
73 , readRev
75 -- * Unfolds
76 , reader
77 , readerRev
79 -- * Casting
80 , cast
81 , asBytes
83 -- * Size
84 , length
86 -- * Re-exports
87 , Unbox (..)
89 -- * Deprecated
90 , newPinned
91 , new
92 , pinnedNew
93 , writeN
94 , write
95 , writeAppendN
96 , writeAppend
97 )
98where
100import Prelude hiding (length, read)
101import Streamly.Internal.Data.MutArray
102import Streamly.Internal.Data.Unbox (Unbox (..))
103import Control.Monad.IO.Class (MonadIO)
105#include "DocTestDataMutArray.hs"
107{-# DEPRECATED newPinned "Please use pinnedNew instead." #-}
108{-# INLINE newPinned #-}
109newPinned :: forall m a. (MonadIO m, Unbox a) => Int -> m (MutArray a)
110newPinned = pinnedNew