[Haskell-cafe] Preferred syntax for append
Hécate
hecate at glitchbra.in
Mon May 13 07:05:03 UTC 2024
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20240513/f4908cae/attachment.html>
More information about the Haskell-Cafe
mailing list