catch instance Foldable ((, ) a)
Andreas Abel
andreas.abel at ifi.lmu.de
Fri May 29 20:24:20 UTC 2020
Tuples are defined in the Prelude, but not used "everywhere". The only
uses are when a function returns several results, like in splitting
list, quotrem etc. These are perfectly fine uses of tuples.
Tuples are for short-lived aggregations of data. Longer living
aggregations deserved telling names for the sake of code comprehension.
In our project Agda we have tons of clones of Bool, Maybe, Either, and
(,) for the sake of giving telling names to data representations. In
short sight this is a "waste of programmer time and effort", but in long
sight this is a major productivity boost. We want to be able to read
and maintain our code written in the 2000s still in the 2020s, and
hopefully 2030s and 2040s.
When you want to "traverse" it is maybe time to name your tuple.
Btw. ((,) a) is more than a Traversable, it is a "Decoration":
https://github.com/agda/agda/blob/c5a36ee4ef4780d0c2980a4e1a04355239c42f34/src/full/Agda/Utils/Functor.hs#L46-L61
It commutes with every Functor, not just with any Applicative.
In the end it comes down what you want to produce. For quick prototypes
and throw-away tools it is fine to use Bool, Maybe, Either and tuples,
but for long-living software I can only recommend to abstain.
Best,
Andreas
On 2020-05-29 16:54, Zemyla wrote:
> On Fri, May 29, 2020, 09:43 Henning Thielemann
> <lemming at henning-thielemann.de <mailto:lemming at henning-thielemann.de>>
> wrote:
>
>
> You can also call it a beginner's problem to use tuples everywhere,
> where
> custom data types would be the better choice.
>
>
> Except the Prelude uses tuples everywhere, as do hundreds of libraries
> based on it, and rewriting all the functions which use them for every
> single decorated data type you plan to use is a waste of programmer time
> and effort.
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
More information about the Libraries
mailing list