Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
e393f213
Commit
e393f213
authored
Sep 22, 2020
by
Sylvain Henry
Committed by
Marge Bot
Oct 01, 2020
Browse files
Allow fusion with catMaybes (#18574)
Metric Decrease: T18574
parent
0bb02873
Changes
2
Hide whitespace changes
Inline
Side-by-side
libraries/base/Data/Maybe.hs
View file @
e393f213
...
...
@@ -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
...
...
libraries/base/changelog.md
View file @
e393f213
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment