<div><br></div><div><br><br><div class="gmail_quote">On Wed, Sep 7, 2011 at 8:07 PM, Cale Gibbard <span dir="ltr"><<a href="mailto:cgibbard@gmail.com">cgibbard@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I just tried this in ghci-7.0.3:<br>
<br>
ghci> nubBy (>=) [1,2,3,4]<br>
[1]<br>
<br>
Think about what this is doing: it is excluding 2 from the list<br>
because 2 >= 1, rather than including it because 1 >= 2 fails.<br>
<br>
I think an important convention when it comes to higher order<br>
functions on lists is that to the extent which is possible, the<br>
function parameters take elements from the list (or things computed<br>
from those) in the order in which they occur in the original list.<br>
<br>
If we reimplement it in the obvious way:<br>
ghci> let nubBy f [] = []; nubBy f (x:xs) = x : filter (not . f x) (nubBy f xs)<br>
ghci> nubBy (>=) [1,2,3,4]<br>
[1,2,3,4]<br>
<br>
I'm aware that the Report (strangely!) explicitly leaves the behaviour<br>
of nubBy unspecified for functions which are not equivalence<br>
relations, but the behaviour given by the Report implementation (the<br>
opposite of the current behaviour in GHC) is useful and desirable<br>
nonetheless.<br>
<br>
I'm sure I've written about this before. I'm not entirely sure what<br>
happened to the previous thread of discussion about this, but it just<br>
came up again for me, and I decided that I was sufficiently irritated<br>
by it to post again.<br></blockquote><div><br></div>I would suggest you rephrase this as a formal proposal, then I can happily vote +1.</div><div class="gmail_quote"><br></div><div class="gmail_quote">I'd also suggest rephrasing rhe mapAccumR as a formal proposal. I'm not sure yet of whether or not I'd be behind that one, but make both proposals separately, so they can pass individually. </div>
<div class="gmail_quote"><br></div><div class="gmail_quote">A short email with the proposed change, and the "Discussion period: 2 weeks" will either make this happen or not. This informal discussion, as it isn't backing an actual proposal is just going to burn everyone out on the topic and leave us where we started.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">-Edward</div></div>