
+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