Eq instance for (a,b,c,d,e) and upwards
Simon Peyton-Jones
simonpj@microsoft.com
Wed, 30 May 2001 03:37:10 -0700
Folks,
I'm about to put out (what I hope is) the final revised Haskell98
report.
Here, though, is one good point I propose to clarify. I propose to say
that
every H98 impl must support tuples up to size 7
and their instances for Eq, Ord, Bounded, Read, Show
[Of course, one might hope that impls would do better, but the report
should be conservative.]
Simon
| -----Original Message-----
| From: Olaf Chitil [mailto:olaf@cs.york.ac.uk]=20
| Sent: 23 April 2001 12:11
| To: nhc-users@cs.york.ac.uk
| Cc: haskell@haskell.org; Simon Peyton-Jones
| Subject: Re: Eq instance for (a,b,c,d,e) and upwards
|=20
|=20
|=20
| I think that this discussion about tuples shows that there is=20
| a problem with the Haskell 98 report which should be=20
| corrected. I hope Simon accepts it as a minor bug fix.
|=20
| 1) The current wording of paragraph 6.1.4 is highly ambigious.
|=20
| > 6.1.4 Tuples
| > =20
| > 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=20
| libraries
| > define tuple functions such as zip for tuples up to a=20
| size of 7. All
| > tuples are instances of Eq, Ord, Bounded, Read, and Show. Classes
| > defined in the libraries may also supply instances for=20
| tuple types.
|=20
| May the limit for the size of tuples and the limit for=20
| instances be different? Do tuples exist at least for a size=20
| up to 7? What is the purpose of the last sentence?
|=20
| We should decide what we want and the paragraph should then=20
| state it clearly.
|=20
| 2) The arbitrary restrictions that Haskell implementations=20
| are permitted to apply, basically imply that you shouldn't=20
| use tuples at all if you want your code to be portable. Maybe=20
| there isn't even a Show instance for ()?
|=20
| So I think the report should demand that tuples and instances=20
| for Eq,Ord,Bounded,Read and Show should be implemented for at=20
| least up to a size of a given number n.
|=20
| 3) I propose this number n to be 7. This fits well with the=20
| fact that zip etc are defined for tuples up to a size of 7. I=20
| agree with Martin that you should use a labelled record or at=20
| least an own type instead of large tuples anyway.=20
| Programs that generate code should als generate definitions=20
| for data types, if large product types are needed.=20
|=20
| Olaf
|=20
| --=20
| OLAF CHITIL,=20
| Dept. of Computer Science, University of York, York YO10 5DD, UK.=20
| URL: http://www.cs.york.ac.uk/~olaf/
| Tel: +44 1904 434756; Fax: +44 1904 432767
|=20