Hi Mark,
Yes I would favour Rebecca's approach in her book to use Semigroup. Personally I never think of lists as Monads, as I see this instance useful only to power list comprehension.
Concatenation with (<>) is more meaningful and holds better
semantics than (<|>), described as just "An associative
binary operation". It's so vague it could be the documentation
for a Magma typeclass, and the name "Alternative" is quite loaded
(we think especially of parsers when thinking/seeing Alternative).
Cheers,
Hécate
We know that lists have map. Sometimes we want to take the higher perspective of Functor, replacing map with fmap, then replacing fmap with <$> . This post asks the corresponding question about append.
The notation for append within List itself is ++ . Often we think of lists as Monads. Applicative generalizes Monad, and Alternative specializes Applicative. Alternative has <|> which behaves as ++ on List. I have been using <|> for this purpose.
Recently, I have begun to read and enjoy "Effective Haskell". In Chapter 1, this book uses <> for append. Clearly they are thinking of List as a Semigroup.
I'm curious about your thoughts on ++ versus <|> versus <> .
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- Hécate ✨ 🐦: @TechnoEmpress IRC: Hecate WWW: https://glitchbra.in RUN: BSD