Re: A sample revised prelude for numeric classes

2001-02-13 Thread Marcin 'Qrczak' Kowalczyk
Tue, 13 Feb 2001 14:01:25 -0500, Dylan Thurston <[EMAIL PROTECTED]> pisze: > Consequences: you cannot, e.g., raise a Double to an Integer power > without an explicit conversion or calling a different function (or > declaring your own instance). Is this acceptable? I don't like it: (-3::Double)^

Re: A sample revised prelude for numeric classes

2001-02-13 Thread Dylan Thurston
On Mon, Feb 12, 2001 at 12:26:35AM +, Marcin 'Qrczak' Kowalczyk wrote: > I must say I like it. It has a good balance between generality and > usefulness / convenience. > > Modulo a few details, see below. > > > > class (Num a, Additive b) => Powerful a b where > > > (^) :: a -> b -> a >

Re: A sample revised prelude for numeric classes

2001-02-12 Thread William Lee Irwin III
On Sun, Feb 11, 2001 at 09:17:53PM -0800, William Lee Irwin III wrote: >> mod an ideal generated by a polynomial, e.g. 1/(1-x) mod (1+x^2). On Mon, Feb 12, 2001 at 01:23:53PM -0500, Dylan Thurston wrote: > Sorry, isn't (1+x^2) invertible in Z[[x]]? You've caught me asleep at the wheel again. Try

Re: A sample revised prelude for numeric classes

2001-02-12 Thread Dylan Thurston
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) ->

Re: A sample revised prelude for numeric classes

2001-02-12 Thread Dylan Thurston
On Mon, Feb 12, 2001 at 07:24:31AM +, Marcin 'Qrczak' Kowalczyk wrote: > Sun, 11 Feb 2001 22:27:53 -0500, Dylan Thurston <[EMAIL PROTECTED]> pisze: > > Reading this, it occurred to me that you could explictly declare an > > instance of Powerful Integer Integer and have everything else work. >

Re: A sample revised prelude for numeric classes

2001-02-12 Thread Dylan Thurston
On Mon, Feb 12, 2001 at 05:24:37PM +1300, Brian Boutel wrote: > > Thus these laws should be interpreted as guidelines rather than > > absolute rules. In particular, the compiler is not allowed to use > > them. Unless stated otherwise, default definitions should also be > > taken as laws. > > In

Re: A sample revised prelude for numeric classes

2001-02-12 Thread Marcin 'Qrczak' Kowalczyk
Mon, 12 Feb 2001 12:04:39 +0100 (CET), Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> pisze: > This is my bet. I changed my mind: class Eq a => PartialOrd a where -- or Ord (<), (>), (<=), (>=) :: a -> a -> Bool -- Minimal definition: (<) or (<=). -- For partial orde

Re: A sample revised prelude for numeric classes

2001-02-12 Thread David Barton
This is pretty rare, and it's also fairly tough to represent points in spaces of fractional dimension. I'll bet the sorts of complications necessary to do so would immediately exclude it from consideration in the design of a standard library, but nevertheless would be interesting to

Re: A sample revised prelude for numeric classes

2001-02-12 Thread Marcin 'Qrczak' Kowalczyk
On Mon, 12 Feb 2001, John Meacham wrote: > My one request is that if at all possible, make some sort of partial > ordering class part of the changes, they are just way to useful in all > types of programs to not have a standard abstraction. I like the idea of having e.g. (<) and (>) not necessar

Re: A sample revised prelude for numeric classes

2001-02-12 Thread Jon Fairbairn
On 12 Feb 2001, Ketil Malde wrote: > [EMAIL PROTECTED] (Marcin 'Qrczak' Kowalczyk) writes: > > >> Why do you stop at allowing addition on Dollars and not include > >> multiplication by a scalar? > > > Perhaps because there is no good universal type for (*). > > Sorry, it would have to have a di

Re: A sample revised prelude for numeric classes

2001-02-12 Thread Ketil Malde
[EMAIL PROTECTED] (Marcin 'Qrczak' Kowalczyk) writes: >> Why do you stop at allowing addition on Dollars and not include >> multiplication by a scalar? > Perhaps because there is no good universal type for (*). > Sorry, it would have to have a different symbol. Is this ubiquitous enough that we

Re: A sample revised prelude for numeric classes

2001-02-12 Thread John Meacham
I quadruple the vote that the basic algebra proposal is too complicated. However I don't see how one could write even moderately complex programs and not wish for a partial ordering class or the ability to use standard terms for groups and whatnot. the current proposal is much more to my liking.

Re: A sample revised prelude for numeric classes

2001-02-12 Thread Bjorn Lisper
Tom Pledger: >Brian Boutel writes: > : > | Having Units as types, with the idea of preventing adding Apples to > | Oranges, or Dollars to Roubles, is a venerable idea, but is not in > | widespread use in actual programming languages. Why not? >There was a pointer to some good papers on this in a

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Marcin 'Qrczak' Kowalczyk
Sun, 11 Feb 2001 22:27:53 -0500, Dylan Thurston <[EMAIL PROTECTED]> pisze: > Reading this, it occurred to me that you could explictly declare an > instance of Powerful Integer Integer and have everything else work. No, because it overlaps with Powerful a Integer (the constraint on a doesn't matt

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Marcin 'Qrczak' Kowalczyk
Sun, 11 Feb 2001 18:48:42 -0800, William Lee Irwin III <[EMAIL PROTECTED]> pisze: > class Ord a => MeetSemiLattice a where > meet :: a -> a -> a > > class MeetSemiLattice a => CompleteMeetSemiLattice a where > bottom :: a > > class Ord a => JoinSemiLattice a where > join :: a

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Marcin 'Qrczak' Kowalczyk
Sun, 11 Feb 2001 16:03:37 -0800, Ashley Yakeley <[EMAIL PROTECTED]> pisze: > Apologies if this has been discussed and I missed it. When it comes to > writing a 'geek' prelude, what was wrong with the Basic Algebra Proposal > found in ? >

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Marcin 'Qrczak' Kowalczyk
Mon, 12 Feb 2001 17:24:37 +1300, Brian Boutel <[EMAIL PROTECTED]> pisze: > > class (Additive a) => Num a where > > (*) :: a -> a -> a > > one :: a > > fromInteger :: Integer -> a > > > > -- Minimal definition: (*), one > > fromInteger 0 = zero > >

Re: A sample revised prelude for numeric classes

2001-02-11 Thread William Lee Irwin III
At 2001-02-11 21:18, Tom Pledger wrote: >>The main complication is that the type system needs to deal with >>integer exponents of dimensions, if it's to do the job well. On Sun, Feb 11, 2001 at 10:16:02PM -0800, Ashley Yakeley wrote: > Very occasionally non-integer or 'fractal' exponents of dimen

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Ashley Yakeley
At 2001-02-11 21:18, Tom Pledger wrote: >The main complication is that the type system needs to deal with >integer exponents of dimensions, if it's to do the job well. Very occasionally non-integer or 'fractal' exponents of dimensions are useful. For instance, geographic coastlines can be measu

Re: A sample revised prelude for numeric classes

2001-02-11 Thread William Lee Irwin III
On Mon, Feb 12, 2001 at 05:24:37PM +1300, Brian Boutel wrote: > Including laws was discussed very early in the development of the > language, but was rejected. IIRC Miranda had them. The argument against > laws was that their presence might mislead users into the assumption > that they did hold, y

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Tom Pledger
Brian Boutel writes: : | Having Units as types, with the idea of preventing adding Apples to | Oranges, or Dollars to Roubles, is a venerable idea, but is not in | widespread use in actual programming languages. Why not? There was a pointer to some good papers on this in a previous discussion

Re: A sample revised prelude for numeric classes

2001-02-11 Thread William Lee Irwin III
On Sun, Feb 11, 2001 at 10:56:29PM -0500, Dylan Thurston wrote: > It follows: > zero * x === (one - one) * x === one * x - one * x === x - x === zero Heh, you've caught me sleeping. =) On Sun, Feb 11, 2001 at 10:56:29PM -0500, Dylan Thurston wrote: > I tried to write the definitions in a way t

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Brian Boutel
Dylan Thurston wrote: > > I've started writing up a more concrete proposal for what I'd like the > Prelude to look like in terms of numeric classes. Please find it > attached below. It's still a draft and rather incomplete, but please > let me know any comments, questions, or suggestions. > >

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Dylan Thurston
On Sun, Feb 11, 2001 at 06:48:42PM -0800, William Lee Irwin III wrote: > There is an additional property of zero being neglected here, namely > that it is an annihilator. That is, > > zero * x === zero > x * zero === zero It follows: zero * x === (one - one) * x === one * x - one

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Fergus Henderson
On 11-Feb-2001, Dylan Thurston <[EMAIL PROTECTED]> wrote: > > class (Num a) => Integral a where > > div, mod :: a -> a -> a > > divMod :: a -> a -> (a,a) > > gcd, lcm :: a -> a -> a > > extendedGCD :: a -> a -> (a,a,a) > > > > -- Minimal definition: divMod or (div and mod) > >

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Dylan Thurston
Thanks for the comments! On Mon, Feb 12, 2001 at 12:26:35AM +, Marcin 'Qrczak' Kowalczyk wrote: > I don't like the fact that there is no Powerful Integer Integer. Reading this, it occurred to me that you could explictly declare an instance of Powerful Integer Integer and have everything else

Re: A sample revised prelude for numeric classes

2001-02-11 Thread William Lee Irwin III
At 2001-02-11 14:42, Dylan Thurston wrote: > >I've started writing up a more concrete proposal for what I'd like the > >Prelude to look like in terms of numeric classes. Please find it > >attached below. It's still a draft and rather incomplete, but please > >let me know any comments, questions,

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Joe English
Dylan Thurston wrote: > > I've started writing up a more concrete proposal for what I'd like the > Prelude to look like in terms of numeric classes. I like this proposal a lot. The organization is closer to traditional mathematical structures than the current Prelude, but not as intimidating as

Re: A sample revised prelude for numeric classes

2001-02-11 Thread William Lee Irwin III
On Sun, Feb 11, 2001 at 05:42:15PM -0500, Dylan Thurston wrote: > I've started writing up a more concrete proposal for what I'd like the > Prelude to look like in terms of numeric classes. Please find it > attached below. It's still a draft and rather incomplete, but please > let me know any com

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Marcin 'Qrczak' Kowalczyk
Sun, 11 Feb 2001 17:42:15 -0500, Dylan Thurston <[EMAIL PROTECTED]> pisze: > I've started writing up a more concrete proposal for what I'd like > the Prelude to look like in terms of numeric classes. Please find > it attached below. It's still a draft and rather incomplete, > but please let me

Re: A sample revised prelude for numeric classes

2001-02-11 Thread Ashley Yakeley
At 2001-02-11 14:42, Dylan Thurston wrote: >I've started writing up a more concrete proposal for what I'd like the >Prelude to look like in terms of numeric classes. Please find it >attached below. It's still a draft and rather incomplete, but please >let me know any comments, questions, or sug

A sample revised prelude for numeric classes

2001-02-11 Thread Dylan Thurston
I've started writing up a more concrete proposal for what I'd like the Prelude to look like in terms of numeric classes. Please find it attached below. It's still a draft and rather incomplete, but please let me know any comments, questions, or suggestions. Best, Dylan Thurston Revisi