I have a Foldable
of Integer
s which are unbounded and thus I cannot apply a Max
fold to it.
Would it make sense to define Max
instance of Nothing
when a value does not exist? There is Ord a => Semigroup (Max a)
but I cannot find Max
instance for (Ord a) => Option a
.
See foldReduce for more context.
The monoid-extras package offers Data.Monoid.Inf for one-sided bounds. The extended-reals package offers Data.ExtendedReal, which is sometimes more convenient if you want to add both bounds in one shot without privileging one or the other's Monoid
instance or want a fresh Bounded
instance that doesn't rely on the underlying type being Bounded
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With