Some thoughts on Enum, Bounded, and [ x .. y ] notation.
Sometimes I want to write > x :: Foo <- [ .. ] that is, an enumeration with both implicit lower and upper bound. This is useful if the type is both an instance of Enum and Bounded. Example: in module Foo, you have > data Foo = A | B | C deriving ( Enum, Bounded ) and in another module Bar, I want to loop over all possible Foo values, but - I don't want to change the text of Bar after I added one new Foo value (anywhere in the enumeration). A related point: the Haskell definition states that > enumFrom and enumFromThen should be defined with an implicit bound, thus: > enumFrom x = enumFromTo x maxBound > .. This suggests that this `maxBound' is the method of class Bounded. I think this should be enforced - the *only* method in Enum should be `enumFromTo'. If one writes [ x .. ], then the compiler expands this to `enumFromTo x maxBound', and therefore adds a `Bounded' constraint. Likewise, [ .. y ] expands to `enumFromTo minBound y', and [ .. ] to `enumFromTo minBound maxBound' . I think this would make matters more simple and orthogonal. PS: and enumFromThenTo should just be removed, alongside n+k patterns :-) -- -- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ -- -- [EMAIL PROTECTED] -- phone/fax (+49) 341 9732 204/209 -- _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell