In hoc signo vinces (Was: Revamping the numeric classes)

Jerzy Karczmarczuk [email protected]
Mon, 12 Feb 2001 16:40:06 +0000


Marcin Kowalczyk continues:

> On Mon, 12 Feb 2001, Jerzy Karczmarczuk wrote:
> 
> > I want to be *able* to define mathematical operations upon objects
> > which by their intrinsic nature permit so!
> 
> You can't do it in Haskell as it stands now, no matter what the Prelude
> would be.
> 
> For example I would say that with the definition
>     abs x = if x >= 0 then x else -x
> it's obvious how to obtain abs :: ([Int]->Int) -> ([Int]->Int): apply the
> definition pointwise.
> 
> But it will never work in Haskell, unless we changed the type rules for if
> and the tyoe of the result of (>=).
> 
> You are asking for letting
>     abs x = max x (-x)
> work on functions. OK, in this particular case it can be made to work 
 ....

Why don't you try from time to time to attempt to understand what
other people want? And wait, say 2 hours, before responding? 

I DON'T WANT max TO WORK ON FUNCTIONS. I never did. I will soon (because
I am writing a graphical package where max serves to intersect implicit
graphical objects) need that, but for very specific functions which
represent textures, but NOT in general.

I repeat for the last time, that I want to have those operations which
are *implied* by the mathematical properties. And anyway, if you replace
x>=0 by x>=zero with an appropriate zero, this should work as well.
I want only that Prelude avoids spurious dependencies.

This is the way I program in Clean, where there is no Num, and (+), (*),
zero, abs, etc. constitute classes by themselves. So, when you say:

> You are asking for an impossible thing.

My impression is what is impossible, is your way of interpreting/
understanding the statements (and/or desiderata) of other people. 

> > I defined hundred times some special functions to add lists or
> > records, to multiply a tree by a scalar (btw.: Jón Fairbarn proposes
> > (.*), I have in principle nothing against, but these operators is used
> > elsewhere, in other languages, CAML and Matlab; I use (*>) ).
> 
> Please show a concrete proposal how Prelude classes could be improved.

(Why do you precede your query by this citation? What do you have to say
here about the syntax proposed by Jón Fairbarn, or whatever??)

I am Haskell USER. I have no ambition to save the world. The "proposal"
has been presented in 1995 in Nijmegen (FP in education). Actually, it
hasn't, I concentrated on lazy power series etc., and the math oriented
prelude has been mentioned casually. Jeroen Fokker presented similar
ideas, implemented differently. 
If you have nothing else to do (but only in this case!) you may find 
the modified prelude called math.hs for Hugs (which needs a modified 
prelude.hs exporting primitives) in 

http://users.info.unicaen.fr/~karczma/humat/

This is NOT a "public proposal" and I *don't want* your public comments
on it. If you want to be nice, show me some of *your* Haskell programs.

Jerzy Karczmarczuk
Caen, France