[Haskell-cafe] history of tuples vs pairs

David Roundy droundy at darcs.net
Wed Jun 25 16:35:34 EDT 2008


On Wed, Jun 25, 2008 at 02:24:57PM -0400, Brent Yorgey wrote:
> On Wed, Jun 25, 2008 at 07:50:08PM +0200, Niels Aan de Brugh wrote:
> > On Wed, 2008-06-25 at 16:50 +0200, Conal Elliott wrote:
> > > I have a foggy memory that early ML had only binary pairing, nesting
> > > for n-tuples.  Can anyone confirm this memory.  If so, does anyone
> > > remember the rationale for going to n-tuples?  Performance, perhaps?
> > 
> > ???What is the difference between a list build up of Cons and a "tuple"
> > made out of pairs? I think the latter wouldn't really add anything new.
> 
> The difference is that all the elements of a list must be the same
> type, whereas nested tuples could have elements of any type.  For
> example,
> 
>   (True, (6, 'c')) :: (Bool, (Int, Char))
> 
> and there is no corresponding three-element list.  However, you're
> right in noting the similarity between lists and nested tuples -- in
> fact, this is exactly how lists are implemented in lisp (which is
> where we get the tern 'cons').

The other difference is that nested tuples have the number of elements
specified in the type, while lists do not.
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Haskell-Cafe mailing list