File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -548,7 +548,7 @@ mapMaybeWithKey f = filterMapAux onLeaf onColl
548
548
where onLeaf (Leaf h (L k v)) | Just v' <- f k v = Just (leaf h k v')
549
549
onLeaf _ = Nothing
550
550
551
- onColl (L k v) | Just v' <- f k v = Just (L k v')
551
+ onColl (L k v) | Just ! v' <- f k v = Just (L k v')
552
552
| otherwise = Nothing
553
553
{-# INLINE mapMaybeWithKey #-}
554
554
Original file line number Diff line number Diff line change @@ -187,6 +187,27 @@ issue379LazyUnionWith = do
187
187
touch v -- makes sure that we didn't GC away the combined value
188
188
assert $ isNothing res
189
189
190
+ ------------------------------------------------------------------------
191
+ -- Issue #381
192
+
193
+ #ifdef HAVE_NOTHUNKS
194
+
195
+ issue381mapMaybe :: Assertion
196
+ issue381mapMaybe = do
197
+ let m0 = HMS. fromList [(KC 1 , 10 ), (KC 2 , 20 :: Int )]
198
+ let m1 = HMS. mapMaybe (Just . (+ 1 )) m0
199
+ mThunkInfo <- noThunksInValues mempty (Foldable. toList m1)
200
+ assert $ isNothing mThunkInfo
201
+
202
+ issue381mapMaybeWithKey :: Assertion
203
+ issue381mapMaybeWithKey = do
204
+ let m0 = HMS. fromList [(KC 1 , 10 ), (KC 2 , 20 :: Int )]
205
+ let m1 = HMS. mapMaybeWithKey (\ (KC k) v -> Just (k + v)) m0
206
+ mThunkInfo <- noThunksInValues mempty (Foldable. toList m1)
207
+ assert $ isNothing mThunkInfo
208
+
209
+ #endif
210
+
190
211
------------------------------------------------------------------------
191
212
-- * Test list
192
213
@@ -206,4 +227,10 @@ tests = testGroup "Regression tests"
206
227
, testCase " Strict.unionWithKey" issue379StrictUnionWithKey
207
228
#endif
208
229
]
230
+ #ifdef HAVE_NOTHUNKS
231
+ , testGroup " issue381"
232
+ [ testCase " mapMaybe" issue381mapMaybe
233
+ , testCase " mapMaybeWithKey" issue381mapMaybeWithKey
234
+ ]
235
+ #endif
209
236
]
You can’t perform that action at this time.
0 commit comments