Re: A sample revised prelude for numeric classes

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 suggestions.
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 ftp://ftp.botik.ru/pub/local/Mechveliani/basAlgPropos/ ? Perhaps it could benefit from multi-parameter classes? -- Ashley Yakeley, Seattle WA

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 suggestions.
On Sun, Feb 11, 2001 at 04:03:37PM -0800, Ashley Yakeley wrote:
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 ftp://ftp.botik.ru/pub/local/Mechveliani/basAlgPropos/ ? Perhaps it could benefit from multi-parameter classes?
I'm not sure if there is anything concrete wrong with it, in fact, I'd like to see it made into a Prelude, but there are several reasons why I don't think it's being discussed here in the context of an alternative for a Prelude. (1) It's widely considered too complex and/or too mathematically involved for the general populace (or whatever semblance thereof exists within the Haskell community). (2) As a "Geek Prelude", it's considered to have some aesthetic and/or usability issues. (3) For persons as insane as myself, it's actually not radical enough. My commentary on it thus far is that I see it as high-quality software that could not only already serve as a "Geek Prelude" for many users, but upon which could also be based implementations and designs of future "Geek Preludes". The fact that no one has discussed it is probably due to a desire not to return to previous flamewars, but it should almost definitely be discussed as a reference point. I've actually been hoping that Mechveliani would chime in and comment on the various ideas, since he's actually already been through the motions of implementing an alternative Prelude and seen what sort of difficulties arise from actually trying to do these things various ways. Cheers, Bill

Sun, 11 Feb 2001 16:03:37 -0800, Ashley Yakeley
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 ftp://ftp.botik.ru/pub/local/Mechveliani/basAlgPropos/ ? Perhaps it could benefit from multi-parameter classes?
Let me quote myself why I don't like this proposal: - It's too complicated. - Relies on controversial type system features, like undecidable instances and overlapping instances. - Relies on type system features that are not implemented and it's not clear if they can be correctly designed or implemented at all, like "domain conversions". - Has many instances that should not exist because the relevant type does not have the class property; they return Nothing or fail, instead of failing to compile. - Properties like commutativity cannot be specified in Haskell. The compiler won't be able to automatically perform any optimizations based on commutativity. - belongs is strange. IMHO it should always return True for valid arguments, and invalid arguments should be impossible to construct if the validity can be checked at all. - Tries to turn a compiled language into an interpreted language. FuncExpr, too much parsing (with arbitrary rules hardwired into the language), too much runtime checks. - It's too complicated. - It's not true that it's "not necessary to dig into mathematics". I studied mathematics and did not have that much of algebra. - I perfer minBound to looking at element under Just under Just under tuple of osetBounds. - Uses ugly character and string arguments that tune the behavior, e.g. in syzygyGens, divRem, canFr. I like Haskell98's divMod+quotRem better. - Uses unneeded sample arguments, e.g. in toEnum, zero, primes, read. - Have I said that it's too complicated? There were lengthy discussions about it... -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK

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. An important thing is that in Haskell it is easy to build up functionality with fine grained control, but difficult or impossible to tear it down, You can't take a complicated class and split it up into smaller independent pieces(not easily at least). but you can take the functionality of several smaller classes and build up a 'bigger' class. Because of this feature one should always err on the side of simplicity and smaller classes when writing re-usable code. I guess what I'm trying to say is that we don't need a Prelude which will provide all of the mathematical structure everyone will need or want, but rather one which doesn't inhibit the ability to build what is needed upon it in a reasonable fashion. (I don't consider un-importing the prelude reasonable for re-usable code and libraries meant to be shared.) in short, three cheers for the new proposal. 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. John -- -------------------------------------------------------------- John Meacham http://www.ugcs.caltech.edu/~john/ California Institute of Technology, Alum. john@foo.net --------------------------------------------------------------

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 necessarily total, and only total compare. It doesn't need to introduce new operations, just split an existing class into two. Only I'm not sure why (<) and (>) should be partial, with (<=) and (>=) total, and not for example opposite. Or perhaps all four partial, with compare, min, max - total. For partial ordering it's often easier to define (<=) or (>=) than (<) or (>). They are related by (==) and not by negation, so it's not exactly the same. I would have PartialOrd with (<), (>), (<=), (>=), and Ord with the rest. Or perhaps with names Ord and TotalOrd respectively? There are several choices of default definitions of these four operators. First of all they can be related either by (==) or by negation. The first works for partial order, the second is more efficient in the case it works (total order). We can have (<=) and (>=) defined in terms of each other, with (<) and (>) defined in terms of (<=) and (>=) - in either way. Or vice versa, but if the definition is in terms of (==), then as I said it's better to let programmers define (<=) or (>=) and derive (<), (>) from them. If they are defined by negation, then we get more efficient total orders, but we must explicitly define both one of (<=), (>=) and one of (<), (>) for truly partial orders, or the results will be wrong. Perhaps it's safer to have inefficient (<), (>) for total orders than wrong for partial orders, even if it means that for optimal performance of total orders one have to define (<=), (<) and (>): class Eq a => PartialOrd a where -- or Ord (<=), (>=), (<), (>) :: a -> a -> Bool -- Minimal definition: (<=) or (>=) a <= b = b >= a a >= b = b <= a a < b = a <= b && a /= b a > b = a >= b && a /= b We could also require to define one of (<=), (>=), and one of (<), (>), for both partial and total orders. Everybody must think about whether he defines (<) as negation of (>=) or not, and it's simpler for the common case of total orders - two definitions are needed. The structure of default definitions is more uniform: class Eq a => PartialOrd a where -- or Ord (<), (>), (<=), (>=) :: a -> a -> Bool -- Minimal definition: (<) or (>), (<=) or (>=) a < b = b > a a > b = b < a a <= b = b >= a a >= b = b <= a This is my bet. -- Marcin 'Qrczak' Kowalczyk

Mon, 12 Feb 2001 12:04:39 +0100 (CET), Marcin 'Qrczak' Kowalczyk
This is my bet.
I changed my mind: class Eq a => PartialOrd a where -- or Ord (<), (>), (<=), (>=) :: a -> a -> Bool -- Minimal definition: (<) or (<=). -- For partial order (<=) is required. -- For total order (<) is recommended for efficiency. a < b = a <= b && a /= b a > b = b < a a <= b = not (b < a) a >= b = b <= a -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
participants (5)
-
Ashley Yakeley
-
John Meacham
-
Marcin 'Qrczak' Kowalczyk
-
qrczak@knm.org.pl
-
William Lee Irwin III