Proposal: (breaking change to avoid fragile breakage) change the definition of foldr2, zip, and zipWith
Simon Peyton Jones
simonpj at microsoft.com
Fri Sep 19 12:05:21 UTC 2014
| David, I think you can go ahead and prepare a patch. People can still
| speak up before (and even after) it is applied if they disagree.
I'm way behind the curve here, but this is really a matter for the Core Libraries Committee, and I gather you are already in good communication with Edward. You can use GHC's Trac for Core Libraries tickets; just use "Core Libraries" for the "Component" field.
Simon
| -----Original Message-----
| From: Libraries [mailto:libraries-bounces at haskell.org] On Behalf Of
| Joachim Breitner
| Sent: 08 September 2014 09:25
| To: David Feuer
| Cc: Haskell Libraries
| Subject: Re: Proposal: (breaking change to avoid fragile breakage)
| change the definition of foldr2, zip, and zipWith
|
| Dear David,
|
|
| Am Montag, den 08.09.2014, 02:58 -0400 schrieb David Feuer:
| > It's been a couple weeks now, and no one's responded.
|
| that can happen. Usually not because noone cares, but because noone
| knows what’s best. And also there was ICFP last week, which probably
| kept people busy ... so don’t be discouraged by silence, and keep
| following up on it.
|
| > On Sun, Aug 24, 2014 at 3:22 PM, David Feuer <david.feuer at gmail.com>
| wrote:
| > > BACKGROUND
| > >
| > > TRAC: #9495
|
| > > SOLUTIONS
| > >
| > > 1. One solution, of course, is to eliminate unfoldr2/right,
| bringing
| > > GHC into compliance with the Report. I really like this idea, but
| > > Joachim thinks it is not worth the potential performance impact on
| > > code written before or without regard for the change. We both
| agree
| > > that a reasonable alternative is
| > >
| > > 3. Modify the baseline definition of unfoldr2 as follows:
| > >
| > > foldr2 :: (a -> b -> c -> c) -> c -> [a] -> [b] -> c
| > > foldr2 k z = go
| > > where
| > > go [] ys = ys `seq` z
| > > go _xs [] = z
| > > go (x:xs) (y:ys) = k x y (go xs ys)
| > >
| > > This should, we believe, make the baseline definition fail where
| the
| > > one fused by foldr2/right would fail, giving consistent semantics.
|
| You already said that I agree with that solution, but I can re-state
| it here :-)
|
| > > WHAT MIGHT BREAK
| > >
| > > Code that currently works but will break with this change has two
| > > properties:
| > >
| > > 1. It relies on the asymmetry in foldr, zipWith, or zip to avoid
| > > running into bottom.
| > > 2. foldr2/right does not fire, either because the second list is
| not
| > > a good producer or because GHC applies the foldr2/left rule
| instead.
| > >
| > > That is, most of the code that this change will break is fragile
| > > under the current scheme.
| > >
| > > DISCUSSION PERIOD
| > >
| > > Standard two weeks.
|
| Given that nobody complained about the standard-non-conformance so far
| I think having a symmetric zip where the RULES are semantics-
| preserving is more useful than strictly following the report. But I
| could be convinced otherwise.
|
|
| David, I think you can go ahead and prepare a patch. People can still
| speak up before (and even after) it is applied if they disagree.
|
| Greetings,
| Joachim
|
| --
| Joachim “nomeata” Breitner
| mail at joachim-breitner.de • http://www.joachim-breitner.de/
| Jabber: nomeata at joachim-breitner.de • GPG-Key: 0xF0FBF51F
| Debian Developer: nomeata at debian.org
More information about the Libraries
mailing list