[Haskell-cafe] Why does Enum succ and pred functions throw exception

Alexander Solla alex.solla at gmail.com
Sat Jun 23 02:24:06 CEST 2012

I hit reply instead of reply all.  Sorry Richard.

On Fri, Jun 22, 2012 at 4:35 PM, <ok at cs.otago.ac.nz> wrote:

> > An ordering does not typically induce a computable enumeration.  For
> > example, there are infinitely many rationals between any pair of
> > rationals.
> I didn't say it was odd that Ords weren't Enums,
> I said that it's odd that Enums aren't Ords.

You said:

"It always struck me as odd that Enum doesn't extend Ord."

Ambiguous, at best.

In any case, the order induced by the enumeration of the rationals is not
compatible with the magnitude/sign order either.  This is typically true.

> It makes little or no sense to make treat rationals as Enums;
> the intent of enums is generally to provide *exhaustive*
> enumeration of a *discrete* set.

I don't see that in the documentation anywhere, and "enumerable" is
synonymous with countable/computable (depending on the context).  The usual
topology on the structure has nothing to do with its enumerability.

The set of pairs of positive integers is "discrete" under the obvious
product topology.  Indeed, the "standard" enumeration is (almost) formally
equivalent to that of the positive rationals.  The only difference is we
aren't skipping over the diagonal.

Enumerating the rationals is straight-forward.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120622/cc4a0c8b/attachment.htm>

More information about the Haskell-Cafe mailing list