<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Feb 7, 2006, at 11:29 AM, Bulat Ziganshin wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Hello Robert,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Tuesday, February 07, 2006, 6:42:41 PM, you wrote:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <BLOCKQUOTE type="cite"><BLOCKQUOTE type="cite"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">More disturbing is the complete inability to write general functions</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">over tuples.</DIV> </BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">RD&gt; As I understand it, you still have to write down the instance <SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">RD&gt; declarations when using '-fgenerics'.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">only one generic instance. it's very much these ideas of using nested</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">tuples, only with special syntax. below is my definitions of Binary</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">class for types with only one constructor:</DIV></BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV>[snip]<DIV><BR class="khtml-block-placeholder"></DIV><DIV>To cut an paste from the GHC manual:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;"> </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">class Bin a where</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">toBin </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">:: a -&gt; [Int]</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">fromBin :: [Int] -&gt; (a, [Int])</SPAN></FONT></DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  <BR class="khtml-block-placeholder"></SPAN></FONT></P><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">toBin {| Unit |}</SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">Unit</SPAN></FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">= []</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">toBin {| a :+: b |} (Inl x) </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">= 0 : toBin x</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">toBin {| a :+: b |} (Inr y) </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">= 1 : toBin y</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">toBin {| a :*: b |} (x :*: y) = toBin x ++ toBin y</SPAN></FONT></DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  <BR class="khtml-block-placeholder"></SPAN></FONT></P><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">fromBin {| Unit |}</SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">bs</SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">      </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">= (Unit, bs)</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">fromBin {| a :+: b |} (0:bs)</SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">= (Inl x, bs')</SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">where (x,bs') = fromBin bs</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">fromBin {| a :+: b |} (1:bs)</SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">= (Inr y, bs')</SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">where (y,bs') = fromBin bs</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">    </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">fromBin {| a :*: b |} bs</SPAN></FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">= (x :*: y, bs'') where (x,bs' ) = fromBin bs</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">(y,bs'') = fromBin bs'</SPAN></FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><P style="margin: 0.0px 0.0px 16.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;">Now you can make a data type into an instance of Bin like this:</SPAN></FONT></P><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">instance (Bin a, Bin b) =&gt; Bin (a,b)</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">  </SPAN></FONT><FONT class="Apple-style-span" color="#6F0F11" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">instance Bin a =&gt; Bin [a]</SPAN></FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>OK. So Now I want a Bin instance for 3-tuples. I have to write down:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>instance (Bin a, Bin b, Bin c) =&gt; Bin (a,b,c)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Fine.  Now I want it for 4-tuples.... </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>instance (Bin a,Bin b,Bin c,Bin d) =&gt; Bin (a,b,c,d)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>See the problem?  Sooner or later (probably sooner) I'll get tired of typing.  I have to write down an 'instance' declaration for each value of n.  Clearly this can't generalize to all n.  So say I'm willing to deal with that and further suppose some super-helpful person writes down all the instances up to n=15 (say) and gets them included in some standard library.  Uh!  Now I discover I need a 17-tuple instance.  OK fine, I have to write down my own special 17-tuple instance.  Suppose (stay with me here), at some later time I import a library written by someone else and they ALSO discovered a need for an instance of this particular class for 17-tuples.  Now our instances overlap!  Double Ugh!  I need to remove one of the instances.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Still the problem is that I can't perform type level induction on the shape of the tuple.  However, I'm willing to concede that generics greatly simplifies the problem -- perhaps to the point where my objections are merely academic.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>OK.  I'm really done now.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><DIV><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Rob Dockins</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Speak softly and drive a Sherman tank.</DIV><DIV>Laugh hard; it's a long way to the bank.</DIV><DIV>          -- TMBG</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN></SPAN> </DIV><BR></DIV></BODY></HTML>