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

Hello. I wonder if there is a function like \x -> (x, x) in the standard libraries. I looked up in Hoogle. It gave me links: 1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du... None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple. I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets. Have a great day.

id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
Hello.
I wonder if there is a function like \x -> (x, x) in the standard libraries.
I looked up in Hoogle. It gave me links:
1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: Hello.
I wonder if there is a function like \x -> (x, x) in the standard libraries.
I looked up in Hoogle. It gave me links:
1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

So, it is not considered harmful. Then I propose we add it to
Data.Tuple under a humane name.
On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson
Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: Hello.
I wonder if there is a function like \x -> (x, x) in the standard libraries.
I looked up in Hoogle. It gave me links:
1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name.
On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson
wrote: Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: Hello.
I wonder if there is a function like \x -> (x, x) in the standard
libraries.
I looked up in Hoogle. It gave me links:
1.
https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou...
2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and * \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times It also pops up in discussions as a counter-example of a linear function: dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes! I think it should be added under the name "dup" (short for “duplicate”). - Vlad
On 16 Jul 2019, at 22:29, Lennart Augustsson
wrote: It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
wrote: So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name. On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson
wrote: Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: Hello.
I wonder if there is a function like \x -> (x, x) in the standard libraries.
I looked up in Hoogle. It gave me links:
1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

+1 for "dup", if it is to be included at all.
-- Dan Burton
On Tue, Jul 16, 2019 at 12:56 PM Vladislav Zavialov
It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and
* \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times
It also pops up in discussions as a counter-example of a linear function:
dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes!
I think it should be added under the name "dup" (short for “duplicate”).
- Vlad
On 16 Jul 2019, at 22:29, Lennart Augustsson
wrote: It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
wrote: So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name. On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson
wrote: Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: Hello.
I wonder if there is a function like \x -> (x, x) in the standard
libraries.
I looked up in Hoogle. It gave me links:
1.
https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou...
2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Note that there is already a function named dup in base [1], albeit in
what's probably a low-traffic module (GHC.IO.Device).
As an alternative I would suggest twin, which returns no results from
Stackage Hoogle.
On the other hand, I'm roughly -0.5 on adding this at all; what use case
does it serve that's not better handled with &&&? (Those 22 occurences of id
&&& id seem most likely to provide illumination...)
[1]:
https://hackage.haskell.org/package/base-4.5.1.0/docs/GHC-IO-Device.html#v:d...
On Tue, Jul 16, 2019 at 2:22 PM Dan Burton
+1 for "dup", if it is to be included at all.
-- Dan Burton
On Tue, Jul 16, 2019 at 12:56 PM Vladislav Zavialov
wrote: It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and
* \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times
It also pops up in discussions as a counter-example of a linear function:
dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes!
I think it should be added under the name "dup" (short for “duplicate”).
- Vlad
On 16 Jul 2019, at 22:29, Lennart Augustsson
wrote: It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
wrote: So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name. On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson < lennart@augustsson.net> wrote:
Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: Hello.
I wonder if there is a function like \x -> (x, x) in the standard
libraries.
I looked up in Hoogle. It gave me links:
1.
https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou...
2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

I don't think an obscure GHC IO function needs to be considered with regard
to naming. I don't currently have an opinion about whether to add this.
On Tue, Jul 16, 2019, 6:30 PM Theodore Lief Gannon
Note that there is already a function named dup in base [1], albeit in what's probably a low-traffic module (GHC.IO.Device).
As an alternative I would suggest twin, which returns no results from Stackage Hoogle.
On the other hand, I'm roughly -0.5 on adding this at all; what use case does it serve that's not better handled with &&&? (Those 22 occurences of id &&& id seem most likely to provide illumination...)
[1]: https://hackage.haskell.org/package/base-4.5.1.0/docs/GHC-IO-Device.html#v:d...
On Tue, Jul 16, 2019 at 2:22 PM Dan Burton
wrote: +1 for "dup", if it is to be included at all.
-- Dan Burton
On Tue, Jul 16, 2019 at 12:56 PM Vladislav Zavialov < vladislav@serokell.io> wrote:
It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and
* \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times
It also pops up in discussions as a counter-example of a linear function:
dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes!
I think it should be added under the name "dup" (short for “duplicate”).
- Vlad
On 16 Jul 2019, at 22:29, Lennart Augustsson
wrote: It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
wrote: So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name. On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson < lennart@augustsson.net> wrote:
Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
> > Hello. > > I wonder if there is a function like \x -> (x, x) in the standard
> > I looked up in Hoogle. It gave me links: > > 1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... > 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe > 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du... > > None of these is to the standard library. I wonder if there is an > intentional omission for some important reason? If not, I think
wrote: libraries. this
> function should be added to Data.Tuple. > > I know some of the persons that make decisions here like Category > theory, so I point out this function is mentioned in Categories for > the Working Mathematician, as δ, the diagonal function, on page 3 > (second edition), although set with angular brackets. > > Have a great day. > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

On 2019-07-16 23:21, Dan Burton wrote:
+1 for "dup", if it is to be included at all.
Same here. --Andreas
On Tue, Jul 16, 2019 at 12:56 PM Vladislav Zavialov
mailto:vladislav@serokell.io> wrote: It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and
* \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times
It also pops up in discussions as a counter-example of a linear function:
dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes!
I think it should be added under the name "dup" (short for “duplicate”).
- Vlad
> On 16 Jul 2019, at 22:29, Lennart Augustsson
mailto:lennart@augustsson.net> wrote: > > It's not harmful, but is it common enough to have a name? > > On Tue, Jul 16, 2019, 12:28 Ignat Insarov mailto:kindaro@gmail.com> wrote: > So, it is not considered harmful. Then I propose we add it to > Data.Tuple under a humane name. > > On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson mailto:lennart@augustsson.net> wrote: > > > > Or 'join (,)' > > > > On Tue, Jul 16, 2019, 09:26 Zemyla mailto:zemyla@gmail.com> wrote: > >> > >> id &&& id > >> > >> On Tue, Jul 16, 2019, 10:58 Ignat Insarov mailto:kindaro@gmail.com> wrote: > >>> > >>> Hello. > >>> > >>> I wonder if there is a function like \x -> (x, x) in the standard libraries. > >>> > >>> I looked up in Hoogle. It gave me links: > >>> > >>> 1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... > >>> 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe > >>> 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du... > >>> > >>> None of these is to the standard library. I wonder if there is an > >>> intentional omission for some important reason? If not, I think this > >>> function should be added to Data.Tuple. > >>> > >>> I know some of the persons that make decisions here like Category > >>> theory, so I point out this function is mentioned in Categories for > >>> the Working Mathematician, as δ, the diagonal function, on page 3 > >>> (second edition), although set with angular brackets. > >>> > >>> Have a great day. > >>> _______________________________________________ > >>> Libraries mailing list > >>> Libraries@haskell.org mailto:Libraries@haskell.org > >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries > >> > >> _______________________________________________ > >> Libraries mailing list > >> Libraries@haskell.org mailto:Libraries@haskell.org > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries > _______________________________________________ > Libraries mailing list > Libraries@haskell.org mailto:Libraries@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries _______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

On 07/17/2019 12:26 PM, Andreas Abel wrote:
On 2019-07-16 23:21, Dan Burton wrote:
+1 for "dup", if it is to be included at all.
Same here. --Andreas
And +1 from me. It's a well established name in the literature. /Henrik This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please contact the sender and delete the email and attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. Email communications with the University of Nottingham may be monitored where permitted by law.

I like dup and yes I have written this function hundreds of times. dup = join (,) Would be good to have it in base. On Thu, Jul 18, 2019 at 5:16 PM Henrik Nilsson < Henrik.Nilsson@nottingham.ac.uk> wrote:
On 07/17/2019 12:26 PM, Andreas Abel wrote:
On 2019-07-16 23:21, Dan Burton wrote:
+1 for "dup", if it is to be included at all.
Same here. --Andreas
And +1 from me. It's a well established name in the literature.
/Henrik
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please contact the sender and delete the email and attachment.
Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. Email communications with the University of Nottingham may be monitored where permitted by law.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Does lambda not exist for a reason?
On Tue, 23 Jul 2019 at 22:59, Tony Morris
I like dup and yes I have written this function hundreds of times.
dup = join (,)
Would be good to have it in base.
On Thu, Jul 18, 2019 at 5:16 PM Henrik Nilsson
wrote: On 07/17/2019 12:26 PM, Andreas Abel wrote:
On 2019-07-16 23:21, Dan Burton wrote:
+1 for "dup", if it is to be included at all.
Same here. --Andreas
And +1 from me. It's a well established name in the literature.
/Henrik
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please contact the sender and delete the email and attachment.
Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. Email communications with the University of Nottingham may be monitored where permitted by law.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

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

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-Ca...
-- 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
map (\x->(x,x)) is quite a punctuation soup compared to ‘map dup’.
- Vlad
On 24 Jul 2019, at 16:48, Cale Gibbard
wrote: Does lambda not exist for a reason? _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

-1
We already have a 'dup' function defined in base but it does something
completely different. I see no reason to add a mild abbreviation and force
Haskellers to add yet another silly word to their vocabulary. Library
authors can already create their own set of vocabulary by importing a
common internal module. Base doesn't need to get involved.
On Wed, Jul 24, 2019 at 10:06 AM Cale Gibbard
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-Ca... -- 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
wrote: map (\x->(x,x)) is quite a punctuation soup compared to ‘map dup’.
- Vlad
On 24 Jul 2019, at 16:48, Cale Gibbard
wrote: Does lambda not exist for a reason? _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

I think hiding the function (\x->(x,x)) behind any of these indirections (dup, join (,), or (id&&&id)) is just wilful obfuscation. The clearest and most direct way to understand the function is to use the lambda - it needs no hard-to-remember name. M. On 16 Jul 2019, at 20:56, Vladislav Zavialov wrote:
It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and
* \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times
It also pops up in discussions as a counter-example of a linear function:
dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes!
I think it should be added under the name "dup" (short for “duplicate”).
- Vlad
On 16 Jul 2019, at 22:29, Lennart Augustsson
wrote: It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
wrote: So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name. On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson
wrote: Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: Hello.
I wonder if there is a function like \x -> (x, x) in the standard libraries.
I looked up in Hoogle. It gave me links:
1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

I often define this in my own code (especially arrowful/pointfree code) as ‘dup = join (,)’—a fairly common name for this from the lands of category theory and concatenative programming, and a common abbreviation of ‘duplicate’ in other contexts like the aforementioned dup(2) for file descriptors. It’s fundamental enough a logical operation (contraction) to warrant a name, in my opinion—we already have ‘const’ for weakening and ‘flip’ for exchange. On Wed, Jul 17, 2019, 05:10 Malcolm Wallace via Libraries < libraries@haskell.org> wrote:
I think hiding the function (\x->(x,x)) behind any of these indirections (dup, join (,), or (id&&&id)) is just wilful obfuscation. The clearest and most direct way to understand the function is to use the lambda - it needs no hard-to-remember name.
M.
On 16 Jul 2019, at 20:56, Vladislav Zavialov wrote:
It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and
* \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times
It also pops up in discussions as a counter-example of a linear function:
dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes!
I think it should be added under the name "dup" (short for “duplicate”).
- Vlad
On 16 Jul 2019, at 22:29, Lennart Augustsson
wrote: It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
wrote: So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name. On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson < lennart@augustsson.net> wrote:
Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: Hello.
I wonder if there is a function like \x -> (x, x) in the standard
libraries.
I looked up in Hoogle. It gave me links:
1.
https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou...
2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du...
None of these is to the standard library. I wonder if there is an intentional omission for some important reason? If not, I think this function should be added to Data.Tuple.
I know some of the persons that make decisions here like Category theory, so I point out this function is mentioned in Categories for the Working Mathematician, as δ, the diagonal function, on page 3 (second edition), although set with angular brackets.
Have a great day. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

+1 for dup either exported by Data.Tuple or via Data.Arrow in greater generality. Sent from my iPhone
On Jul 17, 2019, at 1:49 PM, Jon Purdy
wrote: I often define this in my own code (especially arrowful/pointfree code) as ‘dup = join (,)’—a fairly common name for this from the lands of category theory and concatenative programming, and a common abbreviation of ‘duplicate’ in other contexts like the aforementioned dup(2) for file descriptors.
It’s fundamental enough a logical operation (contraction) to warrant a name, in my opinion—we already have ‘const’ for weakening and ‘flip’ for exchange.
On Wed, Jul 17, 2019, 05:10 Malcolm Wallace via Libraries
wrote: I think hiding the function (\x->(x,x)) behind any of these indirections (dup, join (,), or (id&&&id)) is just wilful obfuscation. The clearest and most direct way to understand the function is to use the lambda - it needs no hard-to-remember name. M.
On 16 Jul 2019, at 20:56, Vladislav Zavialov wrote:
It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and
* \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times
It also pops up in discussions as a counter-example of a linear function:
dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes!
I think it should be added under the name "dup" (short for “duplicate”).
- Vlad
On 16 Jul 2019, at 22:29, Lennart Augustsson
wrote: It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
wrote: So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name. On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson
wrote: Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: > > Hello. > > I wonder if there is a function like \x -> (x, x) in the standard libraries. > > I looked up in Hoogle. It gave me links: > > 1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... > 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe > 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du... > > None of these is to the standard library. I wonder if there is an > intentional omission for some important reason? If not, I think this > function should be added to Data.Tuple. > > I know some of the persons that make decisions here like Category > theory, so I point out this function is mentioned in Categories for > the Working Mathematician, as δ, the diagonal function, on page 3 > (second edition), although set with angular brackets. > > Have a great day. > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

On Wed, Jul 17, 2019 at 11:00 AM Edward Kmett
+1 for dup either exported by Data.Tuple or via Data.Arrow in greater generality.
Ditto. +1 for either of these two options.
On Jul 17, 2019, at 1:49 PM, Jon Purdy
wrote: I often define this in my own code (especially arrowful/pointfree code) as ‘dup = join (,)’—a fairly common name for this from the lands of category theory and concatenative programming, and a common abbreviation of ‘duplicate’ in other contexts like the aforementioned dup(2) for file descriptors.
It’s fundamental enough a logical operation (contraction) to warrant a name, in my opinion—we already have ‘const’ for weakening and ‘flip’ for exchange.
On Wed, Jul 17, 2019, 05:10 Malcolm Wallace via Libraries < libraries@haskell.org> wrote:
I think hiding the function (\x->(x,x)) behind any of these indirections (dup, join (,), or (id&&&id)) is just wilful obfuscation. The clearest and most direct way to understand the function is to use the lambda - it needs no hard-to-remember name.
M.
On 16 Jul 2019, at 20:56, Vladislav Zavialov wrote:
It is reasonably common. I have grepped Hackage using https://codesearch.aelve.com/haskell/ and
* \x->(x,x) occurs 203 times * join (,) occurs 53 times * id &&& id occurs 22 times
It also pops up in discussions as a counter-example of a linear function:
dup :: a ->. (a,a) dup x = (x,x) -- does not typecheck with -XLinearTypes!
I think it should be added under the name "dup" (short for “duplicate”).
- Vlad
On 16 Jul 2019, at 22:29, Lennart Augustsson
wrote: It's not harmful, but is it common enough to have a name?
On Tue, Jul 16, 2019, 12:28 Ignat Insarov
wrote: So, it is not considered harmful. Then I propose we add it to Data.Tuple under a humane name. On Tue, 16 Jul 2019 at 19:41, Lennart Augustsson < lennart@augustsson.net> wrote:
Or 'join (,)'
On Tue, Jul 16, 2019, 09:26 Zemyla
wrote: id &&& id
On Tue, Jul 16, 2019, 10:58 Ignat Insarov
wrote: > > Hello. > > I wonder if there is a function like \x -> (x, x) in the standard libraries.
> > I looked up in Hoogle. It gave me links: > > 1. https://hackage.haskell.org/package/utility-ht/docs/Data-Tuple-HT.html#v:dou... > 2. https://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:dupe > 3. https://hackage.haskell.org/package/relude/docs/Relude-Extra-Tuple.html#v:du... > > None of these is to the standard library. I wonder if there is an > intentional omission for some important reason? If not, I think this > function should be added to Data.Tuple. > > I know some of the persons that make decisions here like Category > theory, so I point out this function is mentioned in Categories for > the Working Mathematician, as δ, the diagonal function, on page 3 > (second edition), although set with angular brackets. > > Have a great day. > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
participants (16)
-
Andreas Abel
-
Cale Gibbard
-
Conal Elliott
-
Dan Burton
-
David Feuer
-
Edward Kmett
-
Elliot Cameron
-
Henrik Nilsson
-
Ignat Insarov
-
Jon Purdy
-
Lennart Augustsson
-
Malcolm Wallace
-
Theodore Lief Gannon
-
Tony Morris
-
Vladislav Zavialov
-
Zemyla