<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <pre><i>
</i>><i> > my summary: Data.List.maximumBy is right-biased,
</i>><i> > minimumBy is left-biased, and none of this is documented.
</i>
> Btw. Data.Semigroup exports Min and Max that are both left-biased

The difference between these two pairs of functions that are very similar 
(and one will with high probability first or more frequently use `Data.Semigroup.min/max` until one encounters a data-structure that 
e.g. needs to be sorted in different ways in different contexts, which is when minimumBy/maximumBy enter the stage.)

All five Haskell developers I know personally that I asked about what they expected of the code snippet (that was also given in the GHC issue, #15921):

```
<span class="kt">Data</span><span class="o">.</span><span class="kt">List</span><span class="o">.</span>maximumBy <span class="p">(</span><span class="kt">Data</span><span class="o">.</span><span class="kt">Ord</span><span class="o">.</span>comparing snd<span class="p">)</span> <span class="p">[(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)]
```

expected it to use right-biased ordering in the implementation. (making the outcome `(3, 2)` whereas in reality it will be `(2, 2)`


</span>I believe that we should:

- align the implementations of minimumBy/maximumBy with Data.Semigroup.min/max to make sure it follows the principle of least surprise. 
- If not possible (for instance, if there is a good reason that is as of yet unknown to me to keep the current behaviour), we should improve the current documentation with the current bias behaviour.
  (or potentially instead make it explicitly implementation-defined with a statement like 'you should not assume a specific ordering between items that are considered equal by the chosen relation').



Thank you,


~Wiebe-Marten Wijnja/Qqwy
</pre>
  </body>
</html>