Eq instance for (a,b,c,d,e) and upwards

Olaf Chitil olaf@cs.york.ac.uk
Mon, 23 Apr 2001 12:11:02 +0100


I think that this discussion about tuples shows that there is a problem
with the Haskell 98 report which should be corrected. I hope Simon
accepts it as a minor bug fix.

1) The current wording of paragraph 6.1.4 is highly ambigious.

>     6.1.4  Tuples
>  
>    Tuples are algebraic datatypes with special syntax, as defined
>    in Section 3.8. Each tuple type has a single constructor. There
>    is no upper bound on the size of a tuple. However, some Haskell
>    implementations may restrict the size of tuples and limit the
>    instances associated with larger tuples. The Prelude and libraries
>    define tuple functions such as zip for tuples up to a size of 7. All
>    tuples are instances of Eq, Ord, Bounded, Read, and Show. Classes
>    defined in the libraries may also supply instances for tuple types.

May the limit for the size of tuples and the limit for instances be
different?
Do tuples exist at least for a size up to 7? What is the purpose of the
last sentence?

We should decide what we want and the paragraph should then state it
clearly.

2) The arbitrary restrictions that Haskell implementations are permitted
to apply, basically imply that you shouldn't use tuples at all if you
want your code to be portable. Maybe there isn't even a Show instance
for ()?

So I think the report should demand that tuples and instances for
Eq,Ord,Bounded,Read and Show should be implemented for at least up to a
size of a given number n.

3) I propose this number n to be 7. This fits well with the fact that
zip etc are defined for tuples up to a size of 7.
I agree with Martin that you should use a labelled record or at least an
own type instead of large tuples anyway. 
Programs that generate code should als generate definitions for data
types, if large product types are needed. 

Olaf

-- 
OLAF CHITIL, 
 Dept. of Computer Science, University of York, York YO10 5DD, UK. 
 URL: http://www.cs.york.ac.uk/~olaf/
 Tel: +44 1904 434756; Fax: +44 1904 432767