<br><br><div class="gmail_quote">On Tue, Nov 18, 2008 at 5:16 PM, Brent Yorgey <span dir="ltr"><<a href="mailto:byorgey@seas.upenn.edu">byorgey@seas.upenn.edu</a>></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;">
> class RepTuple a b | a -> b where<br><div class="Ih2E3d">
> toList :: a -> [b]<br>
> tMap :: (b -> b) -> a -> a<br>
><br>
> instance RepTuple (a, a) a where<br>
> toList (a, b) = [a, b]<br>
> tMap f (a, b) = (f a, f b)<br>
><br>
> And so on and so forth for every kind of tuple. Of course, this runs into<br>
> the issue of the single case, for which I used the OneTuple library<br>
> (actually, I wrote my own right now, but I intend to just use the OneTuple<br>
> library).<br>
><br>
<br>
</div>This is reasonable too. It's just a tradeoff of hackishness vs. code<br>
length/tediousness. I.e. in the solution with type-level naturals, you<br>
don't need a separate instance like this for every number you're going<br>
to use. And no one really likes writing things like<br>
tMap f (a,b,c,d,e,g,h,i,j) = ... =)<br>
<div><div></div><div class="Wj3C7c"><br>
-Brent<br>
</div></div></blockquote><div><br>I agree that it'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>