Is there a function \x -> (x, x) in standard libraries?

Cale Gibbard cgibbard at gmail.com
Wed Jul 24 14:05:50 UTC 2019


The advantage of (\x->(x,x)) as a name is that for a small number of
additional characters, the meaning is obvious even if you didn't know
that this thing existed before, and it generalises nicely -- to other
tuples, or a change from using pairs to some other data structure.

Now, I would actually support the idea of having a type class for
categories with such a diagonal map. But this already exists:

http://hackage.haskell.org/package/categories-1.0.7/docs/Control-Category-Cartesian.html
-- See 'diag'.

One thing I think would be really nice is for the proc/do (Arrow)
notation to be defined in terms of the stuff which is currently in the
'categories' package, which ultimately might mean blessing that stuff
a little more. Of course, Conal has also experimented with
interpreting lambdas in terms of similar classes of operations, which
is an extremely powerful idea as well.

On Wed, 24 Jul 2019 at 09:54, Vladislav Zavialov <vladislav at serokell.io> wrote:
>
> map (\x->(x,x)) is quite a punctuation soup compared to ‘map dup’.
>
> - Vlad
>
> > On 24 Jul 2019, at 16:48, Cale Gibbard <cgibbard at gmail.com> wrote:
> >
> > Does lambda not exist for a reason?
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>


More information about the Libraries mailing list