[Haskell-cafe] instance Enum Double considered not entirely great?

Daniel Fischer daniel.is.fischer at googlemail.com
Wed Sep 21 01:23:17 CEST 2011


On Wednesday 21 September 2011, 00:38:12, Maciej Marcin Piechotka wrote:
> +1 for:
> 
> class Eq a => IEEEEq a where
>     (<.) :: a -> a -> Bool
>     (>.) :: a -> a -> Bool
> 
> Regards

-1 for the class name, too easy to miscount the Es.

And perhaps it would be better to add the IEEE compliant(?) comparisons to 
the RealFloat class.

class (RealFrac a, Floating a) => RealFloat a where
    ...    -- lots of stuff we already have
    (==.) :: a -> a -> Bool
    (<.) :: a -> a -> Bool
    ...

However, I don't particularly like adding just a dot, that's too easily 
overlooked. On the other hand, I don't have a compelling idea either. 
(.==.), (.<.) would at least double the chances to spot the difference.

Anyway, +1 for an Ord instance with a total order (consistent with the 
natural order where applicable) and putting the IEEE comparisons somewhere 
else.



More information about the Haskell-Cafe mailing list