Commit e393f213 authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot
Browse files

Allow fusion with catMaybes (#18574)

Metric Decrease:
   T18574
parent 0bb02873
......@@ -256,8 +256,8 @@ listToMaybe = foldr (const . Just) Nothing
-- >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
-- [1,3]
--
catMaybes :: [Maybe a] -> [a]
catMaybes ls = [x | Just x <- ls]
catMaybes :: [Maybe a] -> [a]
catMaybes = mapMaybe id -- use mapMaybe to allow fusion (#18574)
-- | The 'mapMaybe' function is a version of 'map' which can throw
-- out elements. In particular, the functional argument returns
......
......@@ -32,6 +32,9 @@
* Add `MonadFix` and `MonadZip` instances for `Complex`
* Add `Ix` instances for tuples of size 6 through 15
* `catMaybes` is now implemented using `mapMaybe`, so that it is both a "good
consumer" and "good producer" for list-fusion (#18574)
## 4.14.0.0 *TBA*
* Bundled with GHC 8.10.1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment