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) ->
2975
2975
! sPsab = sPsa + size b
2976
2976
2977
2977
2978
- {-# NOINLINE [1] traverseWithIndex #-}
2978
+ #ifdef __GLASGOW_HASKELL__
2979
+ {-# INLINABLE [1] traverseWithIndex #-}
2980
+ #else
2981
+ {-# INLINE [1] traverseWithIndex #-}
2982
+ #endif
2983
+
2979
2984
#ifdef __GLASGOW_HASKELL__
2980
2985
{-# RULES
2981
2986
"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
90
90
, bench " 100" $ nf multiplyDown s100
91
91
, bench " 1000" $ nf multiplyDown s1000
92
92
]
93
+ , bgroup " sequenceA.mapWithIndex/State"
94
+ [ bench " 10" $ nf multiplyDownMap s10
95
+ , bench " 100" $ nf multiplyDownMap s100
96
+ , bench " 1000" $ nf multiplyDownMap s1000
97
+ ]
93
98
, bgroup " traverse/State"
94
99
[ bench " 10" $ nf multiplyUp s10
95
100
, bench " 100" $ nf multiplyUp s100
@@ -242,3 +247,10 @@ multiplyDown = flip evalState 0 . S.traverseWithIndex go where
242
247
s <- get
243
248
put (s - 1 )
244
249
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