File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -2975,7 +2975,12 @@ traverseWithIndex f' (Seq xs') = Seq <$> traverseWithIndexTreeE (\s (Elem a) ->
29752975 ! sPsab = sPsa + size b
29762976
29772977
2978- {-# NOINLINE [1] traverseWithIndex #-}
2978+ #ifdef __GLASGOW_HASKELL__
2979+ {-# INLINABLE [1] traverseWithIndex #-}
2980+ #else
2981+ {-# INLINE [1] traverseWithIndex #-}
2982+ #endif
2983+
29792984#ifdef __GLASGOW_HASKELL__
29802985{-# RULES
29812986"travWithIndex/mapWithIndex" forall f g xs . traverseWithIndex f (mapWithIndex g xs) =
Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ main = do
9090 , bench " 100" $ nf multiplyDown s100
9191 , bench " 1000" $ nf multiplyDown s1000
9292 ]
93+ , bgroup " sequenceA.mapWithIndex/State"
94+ [ bench " 10" $ nf multiplyDownMap s10
95+ , bench " 100" $ nf multiplyDownMap s100
96+ , bench " 1000" $ nf multiplyDownMap s1000
97+ ]
9398 , bgroup " traverse/State"
9499 [ bench " 10" $ nf multiplyUp s10
95100 , bench " 100" $ nf multiplyUp s100
@@ -242,3 +247,10 @@ multiplyDown = flip evalState 0 . S.traverseWithIndex go where
242247 s <- get
243248 put (s - 1 )
244249 return (s * i * x)
250+
251+ multiplyDownMap :: S. Seq Int -> S. Seq Int
252+ multiplyDownMap = flip evalState 0 . sequenceA . S. mapWithIndex go where
253+ go i x = do
254+ s <- get
255+ put (s - 1 )
256+ return (s * i * x)
You can’t perform that action at this time.
0 commit comments