
So why don't we use First and Last with the Alternative interface too?
It's indeed weird the Maybe doesn't react the same way with Alternative and
Monoid.
2011/12/15 Anthony Cowley
On Dec 15, 2011, at 10:19 AM, Brent Yorgey wrote:
On Thu, Dec 15, 2011 at 06:49:13PM +1000, Gregory Crosswhite wrote:
So at the end of the day... what is the point of even making Maybe and
[] instances of Alternative?
The Alternative and Monoid instances for [] are equivalent. However, the Alternative and Monoid instances for Maybe are not. To wit:
(Just (Sum 4)) <|> (Just (Sum 3)) Just (Sum {getSum = 4})
(Just (Sum 4)) `mappend` (Just (Sum 3)) Just (Sum {getSum = 7})
We already have,
First (Just (Sum 4)) `mappend` First (Just (Sum 3)) First {getFirst = Just (Sum {getSum = 4})}
So the overlap of apparent Alternative and Monoid functionality remains. This just represents an opportunity for the caller to select the monoid they want.
Anthony _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe