A sample revised prelude for numeric classes

Dylan Thurston dpt@math.harvard.edu
Mon, 12 Feb 2001 13:23:53 -0500

On Sun, Feb 11, 2001 at 09:17:53PM -0800, William Lee Irwin III wrote:
> Consider taking of the residue of a truly infinite member of Z[[x]]
> mod an ideal generated by a polynomial, e.g. 1/(1-x) mod (1+x^2).
> You can take the residue of each term of 1/(1-x), so x^(2n) -> (-1)^n
> and x^(2n+1) -> (-1)^n x, but you end up with an infinite number of
> (nonzero!) residues to add up and hence encounter the troubles with
> processes not being finite that I mentioned.

Sorry, isn't (1+x^2) invertible in Z[[x]]?

> I think it's nice to have the Cauchy principal value versions of things
> floating around.  I know at least that I've had call for using the CPV
> of exponentiation (and it's not hard to contrive an implementation),
> but I'm almost definitely an atypical user. (Note, (**) does this today.)

Does Cauchy Principal Value have a specific definition I should know?
The Haskell report refers to the APL language report; do you mean that

For the Complex class, that should be the choice.

> I neglected here to add in the assumption that (<=) was a total relation,
> I had in mind antisymmetry of (<=) in posets so that element isomorphism
> implies equality. Introducing a Poset class where elements may be
> incomparable appears to butt against some of the bits where Bool is
> hardwired into the language, at least where one might attempt to use a
> trinary logical type in place of Bool to denote the result of an
> attempted comparison.

I'm still agnostic on the Poset issue, but as an aside, let me mention
that "Maybe Bool" works very well as a trinary logical type.  "liftM2
&&" does the correct trinary and, for instance.

> On Sun, Feb 11, 2001 at 10:56:29PM -0500, Dylan Thurston wrote:
> > But to define <= in terms of meet and join you already need Eq!
> > 
> >   x <= y === meet x y == y
> I don't usually see this definition of (<=), and it doesn't seem like
> the natural way to go about defining it on most machines. The notion
> of the partial (possibly total) ordering (<=) seems to be logically
> prior to that of the meet to me. The containment usually goes:

It may be logically prior, but computationally it's not...  Note that
the axioms for lattices can be stated either in terms of the partial
ordering, or in terms of meet and join.

(In a completely fine-grained ordering heirarchy, I would have the
equation I gave above as a default definition for <=, with the
expectation that most users would want to override it.  Compare my
fromInteger default definition.)

	Dylan Thurston