@@ -28,7 +28,7 @@
2828
2929module Streamly.Internal.Data.MutArray.Type
3030 (
31− -- * Type
31+ -- ** Type
3232 -- $arrayNotes
3333 MutArray (..)
3434 , MutByteArray
@@ -37,7 +37,7 @@ module Streamly.Internal.Data.MutArray.Type
3737 , unpin
3838 , isPinned
3939
40− -- * Constructing and Writing
40+ -- -- * Constructing and Writing
4141 -- ** Construction
4242 , nil
4343
@@ -65,7 +65,7 @@ module Streamly.Internal.Data.MutArray.Type
6565 , writeRevN
6666 -- , writeRev
6767
68− -- ** From containers
68+ -- *** From containers
6969 , fromListN
7070 , pinnedFromListN
7171 , fromList
@@ -76,7 +76,7 @@ module Streamly.Internal.Data.MutArray.Type
7676 , fromStreamD
7777 , fromPureStream
7878
79− -- * Random writes
79+ -- ** Random writes
8080 , putIndex
8181 , putIndexUnsafe
8282 , putIndices
@@ -93,32 +93,32 @@ module Streamly.Internal.Data.MutArray.Type
9393 , swapIndices
9494 , unsafeSwapIndices
9595
96− -- * Growing and Shrinking
97− -- Arrays grow only at the end, though it is possible to grow on both sides
96+ -- ** Growing and Shrinking
97+ -- | Arrays grow only at the end, though it is possible to grow on both sides
9898 -- and therefore have a cons as well as snoc. But that will require two
9999 -- bounds in the array representation.
100100
101− -- ** Appending elements
101+ -- *** Appending elements
102102 , snocWith
103103 , snoc
104104 , snocLinear
105105 , snocMay
106106 , snocUnsafe
107107
108− -- ** Appending streams
108+ -- *** Appending streams
109109 , writeAppendNUnsafe
110110 , writeAppendN
111111 , writeAppendWith
112112 , writeAppend
113113
114− -- * Eliminating and Reading
114+ -- ** Eliminating and Reading
115115
116− -- ** To streams
116+ -- *** To streams
117117 , reader
118118 , readerRevWith
119119 , readerRev
120120
121− -- ** To containers
121+ -- *** To containers
122122 , toStreamDWith
123123 , toStreamDRevWith
124124 , toStreamKWith
@@ -133,7 +133,7 @@ module Streamly.Internal.Data.MutArray.Type
133133 , producerWith
134134 , producer
135135
136− -- ** Random reads
136+ -- *** Random reads
137137 , getIndex
138138 , getIndexUnsafe
139139 , getIndices
@@ -141,7 +141,7 @@ module Streamly.Internal.Data.MutArray.Type
141141 -- , getFromThenTo
142142 , getIndexRev
143143
144− -- * Memory Management
144+ -- ** Memory Management
145145 , blockSize
146146 , arrayChunkBytes
147147 , allocBytesToElemCount
@@ -150,14 +150,14 @@ module Streamly.Internal.Data.MutArray.Type
150150 , resizeExp
151151 , rightSize
152152
153− -- * Size
153+ -- ** Size
154154 , length
155155 , byteLength
156156 -- , capacity
157157 , byteCapacity
158158 , bytesFree
159159
160− -- * In-place Mutation Algorithms
160+ -- ** In-place Mutation Algorithms
161161 , strip
162162 , reverse
163163 , permute
@@ -167,18 +167,18 @@ module Streamly.Internal.Data.MutArray.Type
167167 , mergeBy
168168 , bubble
169169
170− -- * Casting
170+ -- ** Casting
171171 , cast
172172 , castUnsafe
173173 , asBytes
174174 , asPtrUnsafe
175175
176− -- * Folding
176+ -- ** Folding
177177 , foldl'
178178 , foldr
179179 , cmp
180180
181− -- * Arrays of arrays
181+ -- ** Arrays of arrays
182182 -- We can add dimensionality parameter to the array type to get
183183 -- multidimensional arrays. Multidimensional arrays would just be a
184184 -- convenience wrapper on top of single dimensional arrays.
@@ -186,17 +186,17 @@ module Streamly.Internal.Data.MutArray.Type
186186 -- | Operations dealing with multiple arrays, streams of arrays or
187187 -- multidimensional array representations.
188188
189− -- ** Construct from streams
189+ -- *** Construct from streams
190190 , chunksOf
191191 , pinnedChunksOf
192192 , writeChunks
193193
194− -- ** Eliminate to streams
194+ -- *** Eliminate to streams
195195 , flattenArrays
196196 , flattenArraysRev
197197 , fromArrayStreamK
198198
199− -- ** Construct from arrays
199+ -- *** Construct from arrays
200200 -- get chunks without copying
201201 , getSliceUnsafe
202202 , getSlice
@@ -218,7 +218,7 @@ module Streamly.Internal.Data.MutArray.Type
218218 -- , appendSlice
219219 -- , appendSliceFrom
220220
221− -- * Utilities
221+ -- ** Utilities
222222 , roundUpToPower2
223223 , memcpy
224224 , memcmp
@@ -357,8 +357,8 @@ data MutArray a =
357357-- Pinning & Unpinning
358358-------------------------------------------------------------------------------
359359
360−-- | Copy the 'MutArray' to pinned memory if unpinned, else do nothing. The
361−-- overhead is a copy if the input array is unpinned.
360+-- | Return a copy of the array in pinned memory if unpinned, else return the
361+-- original array.
362362{-# INLINE pin #-}
363363pin :: MutArray a -> IO (MutArray a)
364364pin arr@MutArray{..} =
@@ -366,8 +366,8 @@ pin arr@MutArray{..} =
366366 then pure arr
367367 else pinnedClone arr
368368
369−-- | Copy the 'MutArray' to unpinned memory if pinned, else do nothing. The
370−-- overhead is a copy if the input array is pinned.
369+-- | Return a copy of the array in unpinned memory if pinned, else return the
370+-- original array.
371371{-# INLINE unpin #-}
372372unpin :: MutArray a -> IO (MutArray a)
373373unpin arr@MutArray{..} =
@@ -375,6 +375,7 @@ unpin arr@MutArray{..} =
375375 then clone arr
376376 else pure arr
377377
378+-- | Return 'True' if the array is allocated in pinned memory.
378379{-# INLINE isPinned #-}
379380isPinned :: MutArray a -> Bool
380381isPinned MutArray{..} = Unboxed.isPinned arrContents