on master help sign in
Change the order of arguments in writeAppendN (#2172)
commitab74a844327341d66554dd7c917972875cbfc5d1 authorRanjeet Ranjan <ranjeetr@composewell.com> dateTue 13 Dec 2022, 02:42 (4 years ago) parentdae14c5
1 file changed+9−9
core/src/Streamly/Internal/Data/Array/Mut/Type.hs+9−9
core/src/Streamly/Internal/Data/Array/Mut/Type.hs+9−9
@@ -1630,7 +1630,7 @@ foldr f z arr = D.foldr f z $ toStreamD arr
16301630
16311631-- XXX Keep the bound intact to not lose any free space? Perf impact?
16321632
1633−-- | @writeAppendNUnsafe alloc n@ appends up to @n@ input items to the supplied
1633+-- | @writeAppendNUnsafe n alloc@ appends up to @n@ input items to the supplied
16341634-- array.
16351635--
16361636-- Unsafe: Do not drive the fold beyond @n@ elements, it will lead to memory
@@ -1641,10 +1641,10 @@ foldr f z arr = D.foldr f z $ toStreamD arr
16411641-- /Internal/
16421642{-# INLINE_NORMAL writeAppendNUnsafe #-}
16431643writeAppendNUnsafe :: forall m a. (MonadIO m, Unbox a) =>
1644− m (Array a)
1645− -> Int
1644+ Int
1645+ -> m (Array a)
16461646 -> Fold m a (Array a)
1647−writeAppendNUnsafe action n =
1647+writeAppendNUnsafe n action =
16481648 fmap fromArrayUnsafe $ FL.foldlM' step initial
16491649
16501650 where
@@ -1669,12 +1669,12 @@ writeAppendNUnsafe action n =
16691669-- | Append @n@ elements to an existing array. Any free space left in the array
16701670-- after appending @n@ elements is lost.
16711671--
1672−-- >>> writeAppendN initial n = Fold.take n (Array.writeAppendNUnsafe initial n)
1672+-- >>> writeAppendN n initial = Fold.take n (Array.writeAppendNUnsafe n initial)
16731673--
16741674{-# INLINE_NORMAL writeAppendN #-}
16751675writeAppendN :: forall m a. (MonadIO m, Unbox a) =>
1676− m (Array a) -> Int -> Fold m a (Array a)
1677−writeAppendN initial n = FL.take n (writeAppendNUnsafe initial n)
1676+ Int -> m (Array a) -> Fold m a (Array a)
1677+writeAppendN n initial = FL.take n (writeAppendNUnsafe n initial)
16781678
16791679-- | @writeAppendWith realloc action@ mutates the array generated by @action@ to
16801680-- append the input stream. If there is no reserved space available in the
@@ -1756,7 +1756,7 @@ writeNWith alloc n = FL.take n (writeNWithUnsafe alloc n)
17561756--
17571757-- >>> writeN = Array.writeNWith Array.newPinned
17581758-- >>> writeN n = Fold.take n (Array.writeNUnsafe n)
1759−-- >>> writeN n = Array.writeAppendN (Array.newPinned n) n
1759+-- >>> writeN n = Array.writeAppendN n (Array.newPinned n)
17601760--
17611761{-# INLINE_NORMAL writeN #-}
17621762writeN :: forall m a. (MonadIO m, Unbox a) => Int -> Fold m a (Array a)
@@ -1802,7 +1802,7 @@ writeRevN = writeRevNWith newPinned
18021802-- stream to an 'Array' aligned to the given size.
18031803--
18041804-- >>> writeNAligned align = Array.writeNWith (Array.newAlignedPinned align)
1805−-- >>> writeNAligned align n = Array.writeAppendN (Array.newAlignedPinned align n) n
1805+-- >>> writeNAligned align n = Array.writeAppendN n (Array.newAlignedPinned align n)
18061806--
18071807-- /Pre-release/
18081808--