[Haskell-cafe] Preferred syntax for append
Mark McConnell
mmcconnell17704 at yahoo.com
Tue May 14 17:59:30 UTC 2024
Thanks to all who replied. I will be changing <|> to <> .
On Monday, May 13, 2024 at 03:05:48 AM EDT, Hécate via Haskell-Cafe <haskell-cafe at haskell.org> wrote:
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
Le 12/05/2024 à 21:41, Mark McConnell via Haskell-Cafe a écrit :
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 _______________________________________________
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20240514/51e0d747/attachment.html>
More information about the Haskell-Cafe
mailing list