[Haskell-cafe] Re: default for quotRem in terms of divMod?

Christian Maeder Christian.Maeder at dfki.de
Wed Aug 8 08:40:50 EDT 2007

Isaac Dupree wrote:
> In class Integral, divMod has a default in terms of quotRem.
> (quot,rem,div,mod all have defaults as the both-function they're part
> of.)  I'm sure divMod is more natural than quotRem to implement for some
> types... so why doesn't quotRem have a default in terms of divMod? it
> has no default! Then the "minimal to implement" will change from
> (toInteger and quotRem) to (toInteger and (quotRem or divMod)).
> Isaac

while I don't care if quotRem or divMod should be implemented. I oppose
to give both default implementations in terms of the other.

Already for the class Eq either == or /= must be defined, with the
unpleasant effect that an empty instance like:

  instance Eq T

leads to a loop (when == or /= is called on elements of type T).

The empty instance does not even raise a warning about unimplemented
methods (since the default definition is used).

I'd rather prefer to remove /= as method of Eq.

Cheers Christian

More information about the Haskell-Cafe mailing list