>
> > I find this a little surprising. In general, any algebraic datatype
> > satisfying the conditions in Appendix D of the report should be
> > enumerable, using the same lexicographic ordering used in D.1 for Eq
> > and Ord.
>
> [..]
>
> > Any problems with this?
>
> I've seen one problem in my proposal. It's fine for finite
> datatypes,
> but if at least one of the components is infinite, an
> enumeration will
> not include all the elements. I'm not sure if this is a problem.
>
> Consider
>
> data MyPair = MyPair Integer Integer
> deriving Enum {- not Haskell 98 -}
>
> Now [MyPair 0 0..] will give
>
> [MyPair 0 0, MyPair 0 1, MyPair 0 2, MyPair 0 3, ...]
>
> and will never reach MyPair 1 0.
Miranda has something called diagonalizing list comprehensions if I recall
correctly. I think you would write:
[(a,b) // a <- [1..], b <-[1..]]
and the resulting list would be
[(1,1), (1,2), (2,1) ...]
I might have saved a very old message with miranda code to generate this, if
you're interested.
Regards
Fermin
>
> (A related point is that (toEnum 0) is MyPair 0 0 here; what about
> negative integers?)
>
> --KW 8-)
> --
> : Keith Wansbrough, MSc, BSc(Hons) (Auckland)
> ------------------------:
> : PhD Student, Computer Laboratory, University of Cambridge,
> England. :
> : (and recently of the University of Glasgow, Scotland. [><]
> ) :
> : Native of Antipodean Auckland, New Zealand: 174d47' E,
> 36d55' S. :
> : http://www.cl.cam.ac.uk/users/kw217/
> mailto:[EMAIL PROTECTED] :
>
> :-------------------------------------------------------------
> --------:
>
>