<br><br><div class="gmail_quote">On Tue, Nov 18, 2008 at 5:16 PM, Brent Yorgey <span dir="ltr">&lt;<a href="mailto:byorgey@seas.upenn.edu">byorgey@seas.upenn.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt; class RepTuple a b | a -&gt; b where<br><div class="Ih2E3d">
&gt; &nbsp; &nbsp; toList :: a -&gt; [b]<br>
&gt; &nbsp; &nbsp; tMap :: (b -&gt; b) -&gt; a -&gt; a<br>
&gt;<br>
&gt; instance RepTuple (a, a) a where<br>
&gt; &nbsp; &nbsp; toList (a, b) = [a, b]<br>
&gt; &nbsp; &nbsp; tMap f (a, b) = (f a, f b)<br>
&gt;<br>
&gt; And so on and so forth for every kind of tuple. Of course, this runs into<br>
&gt; the issue of the single case, for which I used the OneTuple library<br>
&gt; (actually, I wrote my own right now, but I intend to just use the OneTuple<br>
&gt; library).<br>
&gt;<br>
<br>
</div>This is reasonable too. &nbsp;It&#39;s just a tradeoff of hackishness vs. code<br>
length/tediousness. I.e. in the solution with type-level naturals, you<br>
don&#39;t need a separate instance like this for every number you&#39;re going<br>
to use. &nbsp;And no one really likes writing things like<br>
tMap f (a,b,c,d,e,g,h,i,j) = ... &nbsp;=)<br>
<div><div></div><div class="Wj3C7c"><br>
-Brent<br>
</div></div></blockquote><div><br>I agree that it&#39;s not something people want to code; I was just thinking that a RepTuple kind of library might be useful for other purposes (ensuring lists of certain length essentially).<br>
<br>Michael<br></div></div>