Tuples aren&#39;t really anything special, you could define your own (2 item) type like:<br><br>data Pair a b = Pair a b<br><br>The main advantage you get with tuple is that first and foremost it&#39;s part of the standard library so it&#39;s used all over the place. It&#39;s really just a convenient shortcut for holding data, and arguably a explicit data type that provides more meta-information about what exactly it contains is usually a better choice rather than the abstract tuple which doesn&#39;t really tell you much of anything. E.G. which is more obvious:<br>
<br>draw :: (Int, Int) -&gt; (Int, Int) -&gt; IO ()<br><br>or<br><br>data Line = Line { startX :: Int, startY :: Int, endX :: Int, endY :: Int }<br>draw :: Line -&gt; IO ()<br><br>More commonly you&#39;d use a tuple to represent a point, but a type declaration to make the signature more explicit as in:<br>
<br>type Point = (Int,Int)<br>draw :: Point -&gt; Point -&gt; IO ()<br><br>or possibly<br><br>type Point = (Int, Int)<br>data Line = Line { lineStart :: Point, lineEnd :: Point }<br>draw :: Line -&gt; IO ()<br><br>The need to have some generic data structure that holds 2 or more other pieces of data however is something you run across so often that from a practical standpoint it makes sense to have it as part of the standard library, particularly for quick and dirty rapid calculations as it&#39;s one less piece of boiler plate throw away you need to worry about creating. In most cases you could even replace a tuple with a list of two elements, but then you lose some of the type safety because lists don&#39;t guarantee the number of elements they contain in the type signature.<br>
<br clear="all">-R. Kyle Murphy<br>--<br>Curiosity was framed, Ignorance killed the cat.<br>
<br><br><div class="gmail_quote">On Mon, Aug 27, 2012 at 9:47 PM, Carlos J. G. Duarte <span dir="ltr">&lt;<a href="mailto:carlos.j.g.duarte@gmail.com" target="_blank">carlos.j.g.duarte@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sorry if this question is too insane, but I was wondering if tuples are really needed in Haskell. I mean, could tuples be generally replaced by variables unroll (f x y z) and explicit data types, or are there some things only possible to do via tuples?<br>

<br>
Thx in advance (and sorry if this looks silly).<br>
<br>
<br>
______________________________<u></u>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/beginners</a><br>
</blockquote></div><br>