<div dir="ltr">I seem to be doing a pretty poor job of communicating my point and should maybe quit while I'm ahead, but one more go:<br><br>I agree that it is good practice to create proper data types rather than using tuples everywhere. I agree with this even more strongly if you're in a 100kloc codebase. It sounds like that's the use case that you're deeply familiar with, Andreas, and it sounds like you've come to correct conclusions <i>in that context</i>.<div><br></div><div>My argument is that there exist other contexts, that you are less familiar with those contexts, and that you should not necessarily expect your experience to fully generalize.</div><div><br></div><div>You're qualified to say that in 100kloc codebases, tuples should exclusively be used for returning multiple values from functions. In that context it's clear that Functor isn't helpful.</div><div><br></div><div>What you seem to be saying, though, is one of two things.</div><div> 1: "In all contexts, you should only ever use tuples for this purpose", or <br> 2: "If you find another purpose to use tuples for, you shouldn't use them as Functors"<br><br>Option 1 requires you to assume that your work on 100kloc codebases generalizes to every use-case of the Haskell programming language. That's pretty bold, especially given that there clearly exist use-cases for which your two stated benefits (readability and maintainability) don't really matter (e.g. writing throwaway scripts).</div><div><br></div><div>Option 2 is more humble in that it allows for the possibility that there's a use-case you're unfamiliar with, but instead it just makes an arbitrary decision that, whatever this unfamiliar use-case is, surely they shouldn't be using Functor. I don't see any way to justify that position.</div><div><br></div><div>---</div><div><br>I don't find anything strange about `minimum (1,2) == 2`, any more than I would find it strange that `minimum (F 1 2) == 2` for any other arbitrary F. I think it's really beside the point, though.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 24, 2016 at 9:04 AM, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">| So, my advice is to use tuples only for very short-lived data, like<br>
| returning multiple results from a function.<br>
<br>
</span>I strongly agree, for all the reasons Andreas mentions. GHC's source code has *lots* of data types that are isomorphic to tuples. Crucial!<br>
<br>
Simon<br>
<span class=""><br>
| -----Original Message-----<br>
| From: Libraries [mailto:<a href="mailto:libraries-bounces@haskell.org">libraries-bounces@haskell.org</a>] On Behalf Of<br>
</span><span class="">| Andreas Abel<br>
| Sent: 24 February 2016 08:58<br>
| To: Nathan Bouscal <<a href="mailto:nbouscal@gmail.com">nbouscal@gmail.com</a>>; <a href="mailto:libraries@haskell.org">libraries@haskell.org</a><br>
| Subject: Re: Haskell Foldable Wats<br>
|<br>
</span><div><div class="h5">| In my n+1 years of participating in a 100kloc Haskell project, I<br>
| learned that programming with the "categorical" data type building<br>
| blocks "Either" and tuples leads to code that is hard to read and<br>
| maintain. It is tempting to use a pair<br>
|<br>
| type QNamed a = (QName, a)<br>
|<br>
| instead of a hand-rolled data type<br>
|<br>
| data QNamed a = QNamed { qname :: QName, qnamedThing :: a }<br>
|<br>
| since with pairs, I get lots of operations for free, and even more if I<br>
| use Functor and Traversable, it seems. However, in the long run, if I<br>
| come back after months to my original code, or even worse, to someone<br>
| else's code, I dearly pay for this:<br>
|<br>
| 1. Harder to read the code, as I may only see the non-telling "fst"<br>
| and "snd" instead of the semantics-loaden "qname" and "qnamedThing".<br>
|<br>
| 2. Lack of code exploration facilities like grep and tags. I can<br>
| grep for "QName" and "qname", but grepping for "," and "fst" returns<br>
| lots of irrelevant locations.<br>
|<br>
| 3. Non-telling error messages.<br>
|<br>
| And all the arguments of using newtypes over type synonyms apply here<br>
| as well.<br>
|<br>
| So, my advice is to use tuples only for very short-lived data, like<br>
| returning multiple results from a function. I am speaking here of<br>
| Haskell as a language for software development, not of Haskell as a<br>
| realization of category theory.<br>
|<br>
| For getting a broader acceptance of Haskell as a language for software<br>
| development, Foldable on tuples is not helpful.<br>
|<br>
| And yes, if I was new to Haskell and learned the GHCI thinks that<br>
|<br>
| minimum (1,2) == 1<br>
|<br>
| then I would advice GHCI to visit some mental institution to get its<br>
| delusions fixed.<br>
|<br>
| --Andreas<br>
|<br>
|<br>
| On 23.02.2016 18:29, Nathan Bouscal wrote:<br>
| > Sorry, poor quoting on my part. I was attempting to reply to<br>
| Andreas's<br>
| > earlier points:<br>
| ><br>
| > >> Use of tuples is highly discourageable…<br>
| >>>I see no point in Functor or Foldable for tuples.<br>
| ><br>
| > On Tue, Feb 23, 2016 at 5:18 PM, Mario Blažević <<a href="mailto:mblazevic@stilo.com">mblazevic@stilo.com</a><br>
| > <mailto:<a href="mailto:mblazevic@stilo.com">mblazevic@stilo.com</a>>> wrote:<br>
| ><br>
| > On 16-02-23 11:23 AM, Nathan Bouscal wrote:<br>
| ><br>
| > It's a bit bold to simultaneously say "Nobody should use this<br>
| > type," and<br>
| > also "If you use this type, you should do it this way." If<br>
| you think<br>
| > that it's bad practice to use tuples, that's a fine and<br>
| respectable<br>
| > opinion, but at that point you should start being a bit more<br>
| > wary about<br>
| > telling those who think otherwise /how/ they should use them.<br>
| ><br>
| ><br>
| > I believe he was referring to lists, not to tuples.<br>
| There<br>
| > were few Prelude functions limited to tuples before FTP, and<br>
| those<br>
| > haven't changed.<br>
| ><br>
| ><br>
| ><br>
| > On Tue, Feb 23, 2016 at 1:10 PM, Marcin Mrotek<br>
| > <<a href="mailto:marcin.jan.mrotek@gmail.com">marcin.jan.mrotek@gmail.com</a><br>
| > <mailto:<a href="mailto:marcin.jan.mrotek@gmail.com">marcin.jan.mrotek@gmail.com</a>><br>
| > <mailto:<a href="mailto:marcin.jan.mrotek@gmail.com">marcin.jan.mrotek@gmail.com</a><br>
| > <mailto:<a href="mailto:marcin.jan.mrotek@gmail.com">marcin.jan.mrotek@gmail.com</a>>>> wrote:<br>
| ><br>
| > > I can assure you that Andreas is not delusional<br>
| ><br>
| > I didn't say that. I was referring to his response to my<br>
| > post, that<br>
| > "Some delusions have very sophisticated explanations."<br>
| ><br>
| > > You have to show good taste or you'll end up with a<br>
| mess<br>
| > that might be logically consistent, but unpleasant to use.<br>
| ><br>
| > This is entirely subjective, and frankly I don't think<br>
| that<br>
| > post-FTP<br>
| > Haskell is a "mess" or is "unpleasant to use". If<br>
| anything,<br>
| > it became<br>
| > more useful to me, because now Prelude functions aren't<br>
| > limited to the<br>
| > one data structure I almost never use.<br>
| ><br>
| > Best regards,<br>
| > Marcin Mrotek<br>
| ><br>
| ><br>
| > _______________________________________________<br>
| > Libraries mailing list<br>
| > <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a> <mailto:<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>><br>
| ><br>
| ><br>
</div></div>| <a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.h" rel="noreferrer" target="_blank">https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.h</a><br>
| > <a href="http://askell.org" rel="noreferrer" target="_blank">askell.org</a>%2fcgi-<br>
| bin%2fmailman%2flistinfo%2flibraries&data=01%7c01%7cs<br>
| ><br>
| imonpj%<a href="http://40064d.mgd.microsoft.com" rel="noreferrer" target="_blank">40064d.mgd.microsoft.com</a>%7ce4033ee9a03a42eaa97108d33cf89187%7c7<br>
| ><br>
| 2f988bf86f141af91ab2d7cd011db47%7c1&sdata=hgiQqaz1dUG2aUrmeYETcy6loEMf<br>
| > xosR3yBA09CQaZs%3d<br>
<span class="">| ><br>
| ><br>
| ><br>
| ><br>
| > _______________________________________________<br>
| > Libraries mailing list<br>
| > <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
| ><br>
</span>| <a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.h" rel="noreferrer" target="_blank">https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.h</a><br>
| > <a href="http://askell.org" rel="noreferrer" target="_blank">askell.org</a>%2fcgi-<br>
| bin%2fmailman%2flistinfo%2flibraries&data=01%7c01%7cs<br>
| ><br>
| imonpj%<a href="http://40064d.mgd.microsoft.com" rel="noreferrer" target="_blank">40064d.mgd.microsoft.com</a>%7ce4033ee9a03a42eaa97108d33cf89187%7c7<br>
| ><br>
| 2f988bf86f141af91ab2d7cd011db47%7c1&sdata=hgiQqaz1dUG2aUrmeYETcy6loEMf<br>
| > xosR3yBA09CQaZs%3d<br>
<span class="">| ><br>
|<br>
|<br>
| --<br>
| Andreas Abel <>< Du bist der geliebte Mensch.<br>
|<br>
| Department of Computer Science and Engineering Chalmers and Gothenburg<br>
| University, Sweden<br>
|<br>
| <a href="mailto:andreas.abel@gu.se">andreas.abel@gu.se</a><br>
</span>| <a href="https://na01.safelinks.protection.outlook.com/?url=http:%2f%2fwww2.tcs" rel="noreferrer" target="_blank">https://na01.safelinks.protection.outlook.com/?url=http:%2f%2fwww2.tcs</a>.<br>
| <a href="http://ifi.lmu.de" rel="noreferrer" target="_blank">ifi.lmu.de</a>%2f~abel%2f&data=01%7C01%7Csimonpj%<a href="http://40064d.mgd.microsoft.com" rel="noreferrer" target="_blank">40064d.mgd.microsoft.com</a>%7<br>
| Ce4033ee9a03a42eaa97108d33cf89187%7C72f988bf86f141af91ab2d7cd011db47%7C<br>
| 1&sdata=kvwlaXofxhQV2ZCD9K%2bemtG4S9oCujNYhn1IXTnSZtc%3d<br>
<span class="">| _______________________________________________<br>
| Libraries mailing list<br>
| <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
</span>| <a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha" rel="noreferrer" target="_blank">https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha</a><br>
| <a href="http://skell.org" rel="noreferrer" target="_blank">skell.org</a>%2fcgi-<br>
| bin%2fmailman%2flistinfo%2flibraries%0a&data=01%7c01%7csimonpj%40064d.m<br>
| <a href="http://gd.microsoft.com" rel="noreferrer" target="_blank">gd.microsoft.com</a>%7ce4033ee9a03a42eaa97108d33cf89187%7c72f988bf86f141af9<br>
| 1ab2d7cd011db47%7c1&sdata=gMTA2SOTm1seAHbvHPWnsDjAa7y1gAS681kW6YUx1mQ%3<br>
| d<br>
</blockquote></div><br></div>