contiguous 0.6.0 → 0.6.1
raw patch · 2 files changed
+25/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Primitive.Contiguous: itraverseP :: (PrimMonad m, Contiguous arr1, Element arr1 a, Contiguous arr2, Element arr2 b) => (Int -> a -> m b) -> arr1 a -> m (arr2 b)
Files
- contiguous.cabal +1/−1
- src/Data/Primitive/Contiguous.hs +24/−0
contiguous.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: contiguous-version: 0.6.0+version: 0.6.1 homepage: https://github.com/andrewthad/contiguous bug-reports: https://github.com/andrewthad/contiguous/issues author: Andrew Martin
src/Data/Primitive/Contiguous.hs view
@@ -163,6 +163,7 @@ , itraverse , itraverse_ , traverseP+ , itraverseP , mapM , forM , mapM_@@ -790,6 +791,29 @@ go 0 unsafeFreeze marr {-# inline traverseP #-}++-- | Map each element of the array to an action, evaluate these+-- actions from left to right, and collect the results in a+-- new array.+itraverseP ::+ ( PrimMonad m+ , Contiguous arr1, Element arr1 a+ , Contiguous arr2, Element arr2 b+ )+ => (Int -> a -> m b)+ -> arr1 a+ -> m (arr2 b)+itraverseP f !arr = do+ let !sz = size arr+ !marr <- new sz+ let go !ix = when (ix < sz) $ do+ a <- indexM arr ix+ b <- f ix a+ write marr ix b+ go (ix + 1)+ go 0+ unsafeFreeze marr+{-# inline itraverseP #-} newtype STA v a = STA {_runSTA :: forall s. Mutable v s a -> ST s (v a)}