<div dir="ltr">On Mon, Jul 21, 2014 at 9:38 AM, Greg Weber <span dir="ltr"><<a href="mailto:greg@gregweber.info" target="_blank">greg@gregweber.info</a>></span> wrote:<div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div class="">On Sun, Jul 20, 2014 at 5:46 PM, John Lato <span dir="ltr"><<a href="mailto:jwlato@gmail.com" target="_blank">jwlato@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The utility of the proposed "equating" extends far beyond simply using it with groupBy.  Just last week I used "on (==)" as part of a complicated boolean expression.<br>


<div><br></div><div>
That said, I just want to be clear that I'm understanding Greg properly.  Are you advocating that one should generally create a newtype+Eq instance rather than using "on (==)"?  What is the benefit of this approach?  The only one I can think of is that it makes the standard libraries smaller, which seems like a rather small gain considering that you've changed a 7-character expression into multi-line boilerplate for everyone, hampering readability in the process.  Is there something I'm missing here?</div>


</div></blockquote><div><br></div></div><div>Sorry I didn't do a good job explaining. groupOn takes a function that is a projection to an equality instance (Eq b => (a -> b)).</div><div>So there is no need for a newtype, and this interface has suited 100% of my needs, and every usage I have ever seen in Haskell code.</div>


<div><br></div><div>My presumption is that the only reason this interface is not 100% satisfactory and we have this weird interface based on Bool is because you may want to compare something that does not have an Eq instance. One could still handle that case by wrapping the projected value in a newtype and writing an Eq instance for that newtype.</div>
</div></div></div></blockquote><div><br></div><div style>I see, thanks for the explanation.  Seems like a reasonable function IMHO.</div><div style><br></div><div style>It still isn't a full replacement for equating though.  In my case, I used "if on (==) someLongSelector a b then ..." to save some characters over the obvious alternative.</div>
</div></div></div>