
On Thursday 23 February 2006 09:53, Ketil Malde wrote:
Wolfgang Jeltsch
writes: Personally, I would greatly prefer to have libraries that do not clash with common Prelude functions.
I would solve this problem by reducing the Prelude to just a core. List function could go, for example, (mostly) into Data.List.
If this means that you must import Data.List almost everywhere, this won't change anything - only add yet another import to every file.
But you could import something different instead! For instance, I can then easily replace Prelude stuff with Edison or some other data structure library. That is what the whole discussion is about. I agree with the rest of what you wrote. Ben

Benjamin Franksen
If this means that you must import Data.List almost everywhere, this won't change anything - only add yet another import to every file.
But you could import something different instead!
Yes. You can do that as it is, of course (well, more or less, at least). The question is who gets the overhead, the users who replace the Prelude or the ones who don't. I still think the people (and the modules) who replace Prelude lists with alternative libraries are outnumbered by those who don't. = = = = Perhaps it would be interesting to run some statistics to see what parts of the Prelude are actually used, and what parts are commonly hidden? Suggestions on how to do that? Grepping for "Prelude" reveals import (- for hiding, + for importing): darcs: - catch (3), init (1), lookup (2), pi (8), log (1) lambdabot: - mod, catch(2), lookup (2), filter (2) + Ord, Bool, Int, flip (Note that a lot of this is for providing backwards compatibility for pre-Data.Map/Set GHC (<6.02))
From my own code, I only hide 'lookup' to avoid clashing with Set and Map. In addition, there's ANSI.lhs (sounds familiar, John? :-) which explicitly imports only the functions it uses from the Prelude, but which can omit the import without any apparent ill effects.
Grepping for "hiding" reveals: darcs: Graphics.UI.WX hiding (when, text), Text.Html hidin (name, text), Directory hiding (getCurrentDirectory, renameFile) lambdabot: System.Random (split) ... clean, test, send ... I'm not sure what to conclude from this, but it seems to me: 1. A lot of the clashes are between Set, Map, and list functionality, so I'm not alone here. 2. Some small collisions between short names occur, but not a huge amount. One could argue for e.g. separating out numeric functions (log, pi), but it's probably not worth it. 3. Avoid exporting generic names like "text", "name", "when" from libraries. Surely these could have been named better? It would of course be more interesting if somebody would check code they have lying around. -k -- If I haven't seen further, it is by standing in the footprints of giants
participants (2)
-
Benjamin Franksen
-
Ketil Malde