
I supply both variants in the monoids package. They are both useful.
+1 from me for adding either or both sets.
The only real issue is the bikeshed problem of naming them.
-Edward Kmett
On Sep 23, 2010, at 12:14 PM, Felipe Lessa
On Thu, Sep 23, 2010 at 12:58 PM, Jake McArthur
wrote: I think this isn't the right link. It should be
http://hackage.haskell.org/trac/ghc/ticket/1952
-- | Ordered monoid under 'max'. newtype Max a = Max { getMax :: a } deriving (Eq, Ord, Read, Show, Bounded)
instance (Ord a, Bounded a) => Monoid (Max a) where mempty = Max minBound Max a `mappend` Max b = Max (a `max` b)
Why should we prefer this monoid over
data Max a = Minimum | Max a deriving (Eq, Ord, Read, Show)
instance Ord a => Monoid (Max a) where mempty = Minimum Minimum `mappend` x = x x `mappend` Minimum = x Max a `mappend` Max b = Max (a `max` b)
Or should we have both variants? Or should we have something like
data AddBounds a = Minimum | This a | Maximum deriving (Eq, Ord, Read, Show)
instance Bounded (AddBounds a) where minBound = Minimum maxBound = Maximum
Cheers! =)
-- Felipe. _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries