Re: [Haskell-cafe] Why the Prelude must die

I agree with Sven, but... What I want to push is a 'mathematically sound' numeric prelude. A proper numerical prelude should have bona fide mathematical obects like groups, rings, and fields underlying common numerical classes. It would be edifying to the student who discovered that the particular data type he is using is an inhabitant of a known class and can thus take advantage of known properties, presupplied as class methods. Reasoning and communication about programs, data types, and functions would be enhanced. [Conjecture 1 (2007). Haskell Mathematical Prelude and Mathematicians] If Haskell had a mathematically sound prelude then more mathematicians would use Haskell. Cheers, Vivian
Message: 1 Date: Sat, 24 Mar 2007 17:56:11 +0100 From: Sven Panne
Subject: Re: [Haskell-cafe] Why the Prelude must die To: haskell-cafe@haskell.org Cc: libraries@haskell.org Message-ID: <200703241756.11121.sven.panne@aedion.de> Content-Type: text/plain; charset="iso-8859-1" 1. Namespace pollution
The Prelude uses many simple and obvious names. Most
On Saturday 24 March 2007 03:48, Stefan O'Rear wrote: programs don't
use the whole Prelude, so names that aren't needed take up namespace with no benefit. [...]
Even though I think that the current Prelude is far from perfect, one should not forget that is a very solid foundation of a "common language": If one sees e.g. '(.)' or 'map', it is immediately clear to everybody what this means, without having to scan through (perhaps long) import lists. Of course one could hide some parts of the Prelude etc., but I think in the long run this only leads to confusion. Redefining common things, heavy use of tons of self-defined operators etc. all make maintenance much harder.
Try reading Lisp code with heavy use of macros or C++ code with tons of overloadings. This is more like Sudoku solving than anything else, because there is no "common language" between the author and the reader anymore.
And taking away the prelude is a little bit like taking away 'int', 'double', 'for', 'while' etc. from the C programmer...
11. Committeeism
Because the Prelude has such a wide audience, a strong committee effect exists on any change to it. This is the worst kind of committeeism, and impedes real progress while polluting the Prelude with little-used features such as fail in Monad (as opposed to MonadZero) and until.
Depending on your viewpoint, you can see this as a plus. Everybody agrees that finalizers are evil, but propose the removal of that method from java.lang.Object to the Java people. :-)
My proposal would be to incrementally improve the Prelude, modularize it a bit more, fix the Num hierarchy, but basically leave it as it is.
Cheers, S.

On Sun, 2007-03-25 at 14:14 +1200, Vivian McPhail wrote:
[Conjecture 1 (2007). Haskell Mathematical Prelude and Mathematicians] If Haskell had a mathematically sound prelude then more mathematicians would use Haskell.
I agree, even though I've only been using Haskell for a few months. Especially if matrix functions were included. Then you can also get category theorists using a practical implementation of some of their theories to solve problems ;-) -- Ivan Lazar Miljenovic

On 3/24/07, Vivian McPhail
I agree with Sven, but...
What I want to push is a 'mathematically sound' numeric prelude. A proper numerical prelude should have bona fide mathematical obects like groups, rings, and fields underlying common numerical classes. It would be edifying to the student who discovered that the particular data type he is using is an inhabitant of a known class and can thus take advantage of known properties, presupplied as class methods. Reasoning and communication about programs, data types, and functions would be enhanced.
One problem with that is that the instances are often times not mathematically sound - Int and Double certainly aren't. Anyway, I agree with the general gist of this idea. However, I think rather than the Prelude, we should just be an interface to the internal stuff, a 'Builtin' module. Actually, there could still be a prelude - it would contain all the common imports (to maintain our decent scores in golf competitions :) ). I also like the idea that the addition of a module line would remove the implicit prelude import - the source code has become 'proper'. Before the module line, the programmer is probably in quick-hack/script mode. Numeric prelude-ness would be good. This brings up an issue - would the numeric classes need to be included/imported in Builtin? To avoid this, I think a bit of evillness (depending on your perspective, i suppose) is necessary - builtin functions would be stuff like AddInts and AddDoubles, not (+). The numeric stuff that provides the classes would also provide instances to wrap the builtin stuff. Hmm, just realized that PreludeBuiltin already exists... Ahwell, I think the renaming is a good idea - classes should not be involved in the builtins.

On 3/24/07, Vivian McPhail
wrote: I agree with Sven, but...
What I want to push is a 'mathematically sound' numeric prelude. A
mgsloan wrote: proper
numerical prelude should have bona fide mathematical obects like groups, rings, and fields underlying common numerical classes. It would be edifying to the student who discovered that the particular data type he is using is an inhabitant of a known class and can thus take advantage of known properties, presupplied as class methods. Reasoning and communication about programs, data types, and functions would be enhanced.
One problem with that is that the instances are often times not mathematically sound - Int and Double certainly aren't.
Int is algebraically sound as a factor ring Z/nZ with n=2**k, k the number of bits (which could be implementation defined). Unfortunately the order inherited from Integer is not compatible with the algebra... Cheers Ben

Vivian McPhail wrote:
What I want to push is a 'mathematically sound' numeric prelude. A proper numerical prelude should have bona fide mathematical obects like groups, rings, and fields underlying common numerical classes. It would be edifying to the student who discovered that the particular data type he is using is an inhabitant of a known class and can thus take advantage of known properties, presupplied as class methods. Reasoning and communication about programs, data types, and functions would be enhanced.
Yes, except that there are not as many groups, rings and fields out there as you think. For one thing, Float and Double are not in any of those. The best you can do with Float and Double is NonAssociativeAlgebra, which is unlikely to be 'edifying'. At least Integer is a proper ring. There is only one field that I am aware of in Haskell (Rational Integer). [Which is sad since Z_p is so easy to code up, and generally extremely useful]. Some classes would become even more important: monoid, groupoid, semi-group, loop (semi-group with identity), etc. But all of those are, to the average programmer (and many a mathematician), just as scary as Monad. And personally, the place my semi-groups show up are not in my data-types, but in my *types*. Jacques

Hi,
(new here)
2007/3/25, Jacques Carette
Some classes would become even more important: monoid, groupoid, semi-group, loop (semi-group with identity), etc. But all of those are, to the average programmer (and many a mathematician), just as scary as Monad.
Of course, when you get that general, you start having the problem that many types can be made into these structures in more than one way. Even the current Monoid class has that problem, even though it has some ties to a particular application (the Writer monad and stuff similar to it -- as reflected in the 'mappend' and 'mconcat' names). You can have newtype wrappers, but that's at least somewhat annoying :-) I'd like to see these classes in the standard library, but I'm not sure at this point whether they are useful enough to have in the prelude, as long as they're not at least losely to a specific application (Field -> numbers; Monoid -> collecting results; Monad -> imperative computations). - Benja

Vivian McPhail wrote:
What I want to push is a 'mathematically sound' numeric prelude. A proper numerical prelude should have bona fide mathematical obects like groups, rings, and fields underlying common numerical classes. .. Some classes would become even more important: monoid, groupoid, semi-group, loop (semi-group with identity), etc. But all of those are, to the average programmer (and many a mathematician), just as scary as Monad.
as long as those concepts, like monads, are clearly defined, consistent, and have practical uses that directly correspond to those concepts and fulfill the laws associated with them, that should not be a hindrance.. ;) ok, tongue out of cheek again, someone would need to investigate the particular shape in which such abstract concepts would be most useful (which may or may not be the same shape best known in maths, see Monad, Monoid, Applicative, Arrow,..), and how those shapes are best expressed within the programming language abilities. and then, of course, someone would need to write code and tutorials. i know there has been a lot more than just talk wrt numeric preludes for haskell, but just now, it took me a while to find the main incumbents, and i could easily have been put off track by other mathematical libraries. when i found that mathematical prelude discussion page at haskell.org, it was disappointingly brief, so i might not have followed through to the sources, which seem rather better developed. when i did go to the darcs site for the sources, there were haddocks, but for introduction and overview, there is only a brief entry for the haskell communities report, in .tex format. perhaps i was mistaken in thinking that there is a group of math-interested haskellers out there discussing, developing, and documenting the area? or perhaps that group needs introductory tutorials presenting its work? long ago, there was a start in Jeroen Fokker's Explaining Algebraic Theory with Functional Programs. FPLE 1995 http://www.cs.uu.nl/people/jeroen/article/algebra/ but what would be today's updated equivalent? claus monad -- one of the secret commands of haskellbot; when uttered on one of the channels haskellbot is lurking on (mailing lists, news groups, irc, blogs, feeds,..), it will generally result in yet another monad tutorial (YAMT) to be written and published; although, if haskellbot is bored, it might simply point randomly to one of its earlier works; documentation on haskellbot commands is sketchy, possibly to discourage trolls, but it has been known to react to "oop in haskell", "killer application", "mainstream", "static vs dynamic typing", and "category theory"

ok, tongue out of cheek again, someone would need to investigate the particular shape in which such abstract concepts would be most useful (which may or may not be the same shape best known in maths, see Monad, Monoid, Applicative, Arrow,..), and how those shapes are best expressed within the programming language abilities. and then, of course, someone would need to write code and tutorials. Agreed. This is why I mentioned semi-groups when someone talked about classical structures like rings and fields. To pick just one example, Kleene Algebras seem more applicable to CS than say fields. Similarly,
My main worry is that this can be a horrible time sink without a clear path to success and, worse, known obstacles in the way. For example: we know that all Monads are Functors, but that is not expressed in the type classes, because it would be too much a pain to do so. That pain is heavily multiplied in a 'proper' subdivision of mathematical types. Until that is fixed, I know I do not consider it worthwhile to spend a lot of time working on this because the end result might be correct, but completely unrealistic. Another obvious item is that the lessons from DoCon have not all been reflected into advances in Haskell, not even Haskell'. If I was in a pessimistic mood, I would mention the lessons from AUTOMATH (you know, stuff from 1968 to the mid 70s). Claus Reinke wrote: there are more rngs and rigs than rings. More applications for non-archimedian fields (power series) than archimedean ones (reals). And so on.
perhaps i was mistaken in thinking that there is a group of math-interested haskellers out there discussing, developing, and documenting the area? or perhaps that group needs introductory tutorials presenting its work? My guess is that there are a number of people "waiting in the wings", waiting for a critical mass of features to show up before really diving in. See http://www.cas.mcmaster.ca/plmms07/ for my reasons for being both interested and wary).
Probably the simplest test case is the difficulties that people are (still) encountering doing matrix/vector algebra in Haskell. One either quickly encounters efficiency issues (although PArr might help), or typing issues (though many tricks are known, but not necessarily simple). Blitz++ and the STL contributed heavily to C++ being taken seriously by people in the scientific computation community. Haskell has even more _potential_, but it is definitely unrealised potential. Jacques

Jacques Carette wrote:
perhaps i was mistaken in thinking that there is a group of math-interested haskellers out there discussing, developing, and documenting the area? or perhaps that group needs introductory tutorials presenting its work? My guess is that there are a number of people "waiting in the wings", waiting for a critical mass of features to show up before really diving in. See http://www.cas.mcmaster.ca/plmms07/ for my reasons for being both interested and wary).
Probably the simplest test case is the difficulties that people are (still) encountering doing matrix/vector algebra in Haskell. One either quickly encounters efficiency issues (although PArr might help), or typing issues (though many tricks are known, but not necessarily simple). Blitz++ and the STL contributed heavily to C++ being taken seriously by people in the scientific computation community. Haskell has even more _potential_, but it is definitely unrealised potential.
I am one of those mathematicians "waiting in the wings." Haskell looked very appealing at first, and the type system seems perfect, especially for things like multilinear algebra where currying and duality is fundamental. I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects. However, I've decided I'm more interested in helping to fix it than wait; so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support. -- View this message in context: http://www.nabble.com/Why-the-Prelude-must-die-tf3457368.html#a9795282 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

Jacques Carette wrote:
perhaps i was mistaken in thinking that there is a group of math-interested haskellers out there discussing, developing, and documenting the area? or perhaps that group needs introductory tutorials presenting its work? My guess is that there are a number of people "waiting in the wings", waiting for a critical mass of features to show up before really diving in. See http://www.cas.mcmaster.ca/plmms07/ for my reasons for being both interested and wary).
Probably the simplest test case is the difficulties that people are (still) encountering doing matrix/vector algebra in Haskell. One either quickly encounters efficiency issues (although PArr might help), or typing issues (though many tricks are known, but not necessarily simple). Blitz++ and the STL contributed heavily to C++ being taken seriously by people in the scientific computation community. Haskell has even more _potential_, but it is definitely unrealised potential.
I am one of those mathematicians "waiting in the wings." Haskell looked very appealing at first, and the type system seems perfect, especially for things like multilinear algebra where currying and duality is fundamental. I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects.
However, I've decided I'm more interested in helping to fix it than wait; so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support.
I've been watching this thread for quite a while now, and it seems to me that there is quite a bit of interest in at least working on a new Prelude. I've also noticed a 'The Other Prelude' page on the wiki [http://haskell.org/haskellwiki/The_Other_Prelude] and they seem to have a start on this. So it seems that we should actually start this, because people will contribute. Can somebody with good Cabal skills and maybe access to darcs.haskell.org start a new library for people to start patching? Bryan Burgers

I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects.
Perhaps we should replace CT with lattice theoretic thinking (e.g. functor = monotonic function) before cleaning up the type-related mess? See: http://citeseer.ist.psu.edu/269479.html
so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support.
I agree: semigoups like lattices are everywhere. Then there could be a uniform treatment of linear algebra, polynomial equations, operator algebra, etc. So, perhaps haste is not a good advice here? -Andrzej

Wouldn't this be a good discussion for the Haskell Prime List? Reilly Hayes +1 415 388 3903 (office) +1 415 846 1827 (mobile) rfh@ridgecrestfinancial.com On Apr 2, 2007, at 3:24 PM, Andrzej Jaworski wrote:
I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects.
Perhaps we should replace CT with lattice theoretic thinking (e.g. functor = monotonic function) before cleaning up the type-related mess? See: http://citeseer.ist.psu.edu/269479.html
so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support.
I agree: semigoups like lattices are everywhere. Then there could be a uniform treatment of linear algebra, polynomial equations, operator algebra, etc. So, perhaps haste is not a good advice here?
-Andrzej
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mon, 2 Apr 2007, jasonm wrote:
Jacques Carette wrote:
perhaps i was mistaken in thinking that there is a group of math-interested haskellers out there discussing, developing, and documenting the area? or perhaps that group needs introductory tutorials presenting its work? My guess is that there are a number of people "waiting in the wings", waiting for a critical mass of features to show up before really diving in. See http://www.cas.mcmaster.ca/plmms07/ for my reasons for being both interested and wary).
Probably the simplest test case is the difficulties that people are (still) encountering doing matrix/vector algebra in Haskell. One either quickly encounters efficiency issues (although PArr might help), or typing issues (though many tricks are known, but not necessarily simple). Blitz++ and the STL contributed heavily to C++ being taken seriously by people in the scientific computation community. Haskell has even more _potential_, but it is definitely unrealised potential.
I am one of those mathematicians "waiting in the wings." Haskell looked very appealing at first, and the type system seems perfect, especially for things like multilinear algebra where currying and duality is fundamental. I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects.
However, I've decided I'm more interested in helping to fix it than wait; so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support.
NumericPrelude popped up in this thread earlier. Is this the starting point you are after? http://darcs.haskell.org/numericprelude/

NumericPrelude does seem like a good starting point for discussion and
addition. Is it still being actively developed, and what are the
goals there?
On 4/3/07, Henning Thielemann
On Mon, 2 Apr 2007, jasonm wrote:
Jacques Carette wrote:
perhaps i was mistaken in thinking that there is a group of math-interested haskellers out there discussing, developing, and documenting the area? or perhaps that group needs introductory tutorials presenting its work? My guess is that there are a number of people "waiting in the wings", waiting for a critical mass of features to show up before really diving in. See http://www.cas.mcmaster.ca/plmms07/ for my reasons for being both interested and wary).
Probably the simplest test case is the difficulties that people are (still) encountering doing matrix/vector algebra in Haskell. One either quickly encounters efficiency issues (although PArr might help), or typing issues (though many tricks are known, but not necessarily simple). Blitz++ and the STL contributed heavily to C++ being taken seriously by people in the scientific computation community. Haskell has even more _potential_, but it is definitely unrealised potential.
I am one of those mathematicians "waiting in the wings." Haskell looked very appealing at first, and the type system seems perfect, especially for things like multilinear algebra where currying and duality is fundamental. I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects.
However, I've decided I'm more interested in helping to fix it than wait; so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support.
NumericPrelude popped up in this thread earlier. Is this the starting point you are after? http://darcs.haskell.org/numericprelude/

On Tue, 3 Apr 2007, Jason Morton wrote:
NumericPrelude does seem like a good starting point for discussion and addition. Is it still being actively developed,
slowly but actively
and what are the goals there?
A more sophisticated numeric type class hierarchy. However it contains also some algorithms, because we have to test if the hierarchy indeed works.
participants (13)
-
Andrzej Jaworski
-
Benja Fallenstein
-
Benjamin Franksen
-
Bryan Burgers
-
Claus Reinke
-
Henning Thielemann
-
Ivan Lazar Miljenovic
-
Jacques Carette
-
Jason Morton
-
jasonm
-
mgsloan
-
R Hayes
-
Vivian McPhail