@@ -128,7 +128,7 @@ import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, elem, notElem, f
128128import Data.Maybe (Maybe (..), maybe , isJust , fromJust )
129129import Data.Traversable (scanl , scanr ) as Exports
130130import Data.Traversable (sequence , traverse )
131- import Data.Tuple (Tuple (..), uncurry )
131+ import Data.Tuple (Tuple (..))
132132import Data.Unfoldable (class Unfoldable , unfoldr )
133133import Partial.Unsafe (unsafePartial )
134134import Unsafe.Coerce (unsafeCoerce )
@@ -658,7 +658,7 @@ mapWithIndex f xs =
658658-- |
659659updateAtIndices :: forall t a . Foldable t => t (Tuple Int a ) -> Array a -> Array a
660660updateAtIndices us xs =
661- ST .run (STA .withArray (\res -> traverse_ (uncurry $ STA .pokeSTArray res) us) xs)
661+ ST .run (STA .withArray (\res -> traverse_ (\( Tuple i a) -> STA .poke i a res) us) xs)
662662
663663-- | Apply a function to the element at the specified indices,
664664-- | creating a new array. Out-of-bounds indices will have no effect.
@@ -671,7 +671,7 @@ updateAtIndices us xs =
671671-- |
672672modifyAtIndices :: forall t a . Foldable t => t Int -> (a -> a ) -> Array a -> Array a
673673modifyAtIndices is f xs =
674- ST .run (STA .withArray (\res -> traverse_ (\i -> STA .modifySTArray res i f) is) xs)
674+ ST .run (STA .withArray (\res -> traverse_ (\i -> STA .modify i f res ) is) xs)
675675
676676-- ------------------------------------------------------------------------------
677677-- Sorting ---------------------------------------------------------------------
@@ -860,14 +860,14 @@ group' = group <<< sort
860860groupBy :: forall a . (a -> a -> Boolean ) -> Array a -> Array (NonEmptyArray a )
861861groupBy op xs =
862862 ST .run do
863- result <- STA .emptySTArray
863+ result <- STA .empty
864864 iter <- STAI .iterator (xs !! _)
865865 STAI .iterate iter \x -> void do
866- sub <- STA .emptySTArray
866+ sub <- STA .empty
867867 STAI .pushWhile (op x) iter sub
868- _ <- STA .pushSTArray sub x
868+ _ <- STA .push x sub
869869 grp <- STA .unsafeFreeze sub
870- STA .pushSTArray result ((unsafeCoerce :: Array ~> NonEmptyArray ) grp)
870+ STA .push ((unsafeCoerce :: Array ~> NonEmptyArray ) grp) result
871871 STA .unsafeFreeze result
872872
873873-- | Remove the duplicates from an array, creating a new array.
@@ -1035,12 +1035,12 @@ zip = zipWith Tuple
10351035unzip :: forall a b . Array (Tuple a b ) -> Tuple (Array a ) (Array b )
10361036unzip xs =
10371037 ST .run do
1038- fsts <- STA .emptySTArray
1039- snds <- STA .emptySTArray
1038+ fsts <- STA .empty
1039+ snds <- STA .empty
10401040 iter <- STAI .iterator (xs !! _)
10411041 STAI .iterate iter \(Tuple fst snd) -> do
1042- void $ STA .pushSTArray fsts fst
1043- void $ STA .pushSTArray snds snd
1042+ void $ STA .push fst fsts
1043+ void $ STA .push snd snds
10441044 fsts' <- STA .unsafeFreeze fsts
10451045 snds' <- STA .unsafeFreeze snds
10461046 pure $ Tuple fsts' snds'
0 commit comments