Arg isn't itself a
Semigroup in its own right, but it
can be placed inside
Min and
Max to compute an arg min
or arg max. In the event of ties, the leftmost qualifying
Arg
is chosen; contrast with the behavior of
minimum and
maximum for many other types, where ties are broken by
considering elements to the left in the structure to be less than
elements to the right.
Examples
>>> minimum [ Arg (x * x) x | x <- [-10 .. 10] ]
Arg 0 0
>>> maximum [ Arg (-0.2*x^2 + 1.5*x + 1) x | x <- [-10 .. 10] ]
Arg 3.8 4.0
>>> minimum [ Arg (-0.2*x^2 + 1.5*x + 1) x | x <- [-10 .. 10] ]
Arg (-34.0) (-10.0)