[GHC] #10457: Revise/remove custom mapM implementation for lists
GHC
ghc-devs at haskell.org
Mon Aug 3 16:19:15 UTC 2015
#10457: Revise/remove custom mapM implementation for lists
-------------------------------------+-------------------------------------
Reporter: dolio | Owner:
Type: task | Status: patch
Priority: normal | Milestone: 7.12.1
Component: libraries/base | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions: Phab:D1124
-------------------------------------+-------------------------------------
Changes (by bgamari):
* differential: Phab:D924 => Phab:D1124
Old description:
> Recently, Simon Marlow asked why the list instance for Traversable had a
> custom mapM implementation that used the Monad operations. Having looked
> a bit, I don't think there's any good reason. The only fusion that the
> custom mapM can participate in is due to it being written as foldr, but
> traverse is, as well. So as long as 'mapM = traverse' is able to inline
> appropriately, there should be no difference.
>
> Further, this can be changed, in principle, for 7.10.2. It doesn't change
> any types, only the implementation.
>
> mapM = traverse is the class default definition, so this could possibly
> be completed by just removing the custom definition.
>
> Link to the libraries thread:
> https://mail.haskell.org/pipermail/libraries/2015-May/025708.html
New description:
Recently, Simon Marlow asked why the list instance for `Traversable` had a
custom `mapM` implementation that used the `Monad` operations. Having
looked a bit, I don't think there's any good reason. The only fusion that
the custom `mapM` can participate in is due to it being written as
`foldr`, but `traverse` is, as well. So as long as `mapM = traverse` is
able to inline appropriately, there should be no difference.
Further, this can be changed, in principle, for 7.10.2. It doesn't change
any types, only the implementation.
`mapM = traverse` is the class default definition, so this could possibly
be completed by just removing the custom definition.
Link to the libraries thread:
https://mail.haskell.org/pipermail/libraries/2015-May/025708.html
--
Comment:
Phab:D924 proposed a redefinition of `mapM_` in addition to the removal of
list's override of `mapM`. This changed the performance characteristics of
user code, as seen in #10711.
I've extracted the removal of the `mapM` override into Phab:D1124 and
forwarded the `mapM_` issue to the Core Libraries Committee.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10457#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list