RE: Enum instance for Ratio

2000-03-15 Thread Simon Peyton-Jones
| Both GHC and Hugs have a bug in their Prelude for Ratio's Enum | instance. The following program | |import Ratio |main = print [ 1, 4%(3::Int) .. 2 ] | | should print | |[1 % 1,4 % 3,5 % 3,2 % 1] | | but instead an infinite list of 1%1s is generated. The reason for this | is

Re: Enum instance for Ratio

2000-03-09 Thread George Russell
Marc van Dongen wrote: Wouldn't that make Enum depend on Ord? Doesn't seem to make sense if classes are enumerable but not comparable. What examples are there of types for which it would be sensible to implement Enum but not Ord? The concept rather puzzles me. In particular, suppose you

Enum instance for Ratio

2000-03-09 Thread Sven Panne
Both GHC and Hugs have a bug in their Prelude for Ratio's Enum instance. The following program import Ratio main = print [ 1, 4%(3::Int) .. 2 ] should print [1 % 1,4 % 3,5 % 3,2 % 1] but instead an infinite list of 1%1s is generated. The reason for this is that the default method for

Re: Enum instance for Ratio

2000-03-09 Thread Marc van Dongen
George Russell ([EMAIL PROTECTED]) wrote: : Marc van Dongen wrote: : Wouldn't that make Enum depend on Ord? : Doesn't seem to make sense if classes are : enumerable but not comparable. Of course above I should have said orderable in stead of comparable. : What examples are there of types

Re: Enum instance for Ratio

2000-03-09 Thread Malcolm Wallace
Sven writes: Both GHC and Hugs have a bug in their Prelude for Ratio's Enum instance. ... The reason for this is that the default method for enumFromThenTo is used, which truncates 4%3 to 1 (same for enumFromTo). I'd say that this is a bug in the Library

Re: Enum instance for Ratio

2000-03-09 Thread George Russell
A logical definition of Enum (to me wearing a mathematical hat) would be succ x = min { y | y x} For Ratio this makes no sense, ergo Ratio should not be an instance of Enum. For Float and Doubles it makes a lot of sense (giving nextAfter, which is a commonly used IEEE function not otherwise

Re: Enum instance for Ratio

2000-03-09 Thread Marc van Dongen
George Russell ([EMAIL PROTECTED]) wrote: : A logical definition of Enum (to me wearing a mathematical hat) : would be : : succ x = min { y | y x} : Wouldn't that make Enum depend on Ord? Doesn't seem to make sense if classes are enumerable but not comparable. Regards, Marc