Maximum and Minimum monoids
Strake
strake888 at gmail.com
Sat Dec 29 14:29:05 CET 2012
On 28/12/2012, Herbert Valerio Riedel <hvr at gnu.org> wrote:
> I just realized what confuses me about this bounded maximum/minimum
> definitions: In the math literature I've been exposed to so far (see
> also [1][2]), to satisify the definition of a maximal/minimal element of
> a set that said element has to be actually contained in that set.
>
> So it seems very confusing to me to call the element resulting from
>
> (Ord a, Bounded a) => Monoid (Max a)
>
> with 'Max a' isomorphic to 'a' a proper "maximum" (as it violates the
> definition for 'mempty'); on the other hand, the term "supremum"[3]
> seems to match the semantics of the Monoid above better.
>
> [1]: http://en.wikipedia.org/wiki/Maximal_element#Definition
> [2]: http://mathworld.wolfram.com/Maximum.html
> [3]: http://en.wikipedia.org/wiki/Supremum
Ah. Yes, thanks for the clarification, to me at least.
So it seems that our type of "maximum" and "minimum" is wrong; rather,
it ought to be this:
maximum, minimum :: (Ord a, Foldable v) => v a -> Maybe a
and (Max a) and (Min a) are not properly monoids.
We could define these:
Supr, Infi :: * -> *
instance (Ord a, Bounded a) => Monoid (Supr a)
instance (Ord a, Bounded a) => Monoid (Infi a)
but I'm not sure whether we ought to.
Cheers,
Strake
More information about the Libraries
mailing list