
Hi, Is it possible to have more than one module defined in a single file ? As far as I can tell, the Haskell Report doesn't prohibit this, but so far my tests with hugs and ghc indicate they don't accept multi-module files. Is this standard ? Thanks. --- []s, Andrei de A. Formiga __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/

hello, according to the report there should be no connection between modules and files, and one should be able to have multiple modules in a file, and even a single module in multiple files. however none of the implementations support that, so in effect there is 1-1 correspondence between modules and files. the reason for this is that it provides an easy way for the implementation to find the modules. -iavor Andrei de A. Formiga wrote:
Hi,
Is it possible to have more than one module defined in a single file ? As far as I can tell, the Haskell Report doesn't prohibit this, but so far my tests with hugs and ghc indicate they don't accept multi-module files. Is this standard ? Thanks.
--- []s, Andrei de A. Formiga
__________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 2004-06-14 at 15:59PDT "Iavor S. Diatchki" wrote:
according to the report there should be no connection between modules and files, and one should be able to have multiple modules in a file, and even a single module in multiple files. however none of the implementations support that, so in effect there is 1-1 correspondence between modules and files.
the reason for this is that it provides an easy way for the implementation to find the modules.
But surely it's also a significant discouragement to those who would write small modules, and therefore a Bad Thing, at least until editing and displaying multiple files is made sufficiently easy? Jón -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk

Jon Fairbairn wrote:
On 2004-06-14 at 15:59PDT "Iavor S. Diatchki" wrote:
according to the report there should be no connection between modules and files, and one should be able to have multiple modules in a file, and even a single module in multiple files. however none of the implementations support that, so in effect there is 1-1 correspondence between modules and files.
the reason for this is that it provides an easy way for the implementation to find the modules.
But surely it's also a significant discouragement to those who would write small modules, and therefore a Bad Thing, at least until editing and displaying multiple files is made sufficiently easy?
Question of perspective... In Pascal, Modula, Python, Clean, you name it, modules and files were always 1 - 1. Somehow this is considered more 'clean', isn't it? What's the problem with editing and displaying multiple files? There are even such systems as Matlab, where each *function* is put into a separate file, and the directory management of the underlying operating system becomes a part of the dynamic loading mechanism... [I find it a bit annoying, but I won't fight against them...]. I believe that our 21st century should finally forsake the old concept of file, as we see it now. A module is an entry in a database. Even standard text documents, because of hyper-links, multi- format, multi-part collections, etc., merit -perhaps - to be regarded not as "files", but as more structured entities... We have already separate 'interface files'... We should use more frequently multi-level editors. We know, anyway, that it is *good* to have some interaction between the editor and the compiler for the debugging... Jerzy Karczmarczuk

G'day all.
Quoting Jerzy Karczmarczuk
Question of perspective... In Pascal, Modula, Python, Clean, you name it, modules and files were always 1 - 1.
A C++ class is basically an instantiable module. In C++, you can implement more than one module in a file, and you can implement a single module in multiple files.
Somehow this is considered more 'clean', isn't it?
It's usually considered good design practice in languages with modules to have one module responsible for one thing. Sometimes this is not possible, for example, if a module is responsible for implementing a major internal abstraction (e.g. "Core" in GHC, "database" in a database server etc). In that situation, it makes sense to distribute implementation of a module across more than one file. In Haskell, of course, you can do this by re-exporting symbols from imported modules; the Prelude is a case in point. Similarly, if a module is considered "private", such as with nested modules (or nested classes in C++), it is arguably cleaner to implement them privately lest someone else import them and use them. This usually means within the module which uses it, i.e., more than one module per file.
What's the problem with editing and displaying multiple files?
This reminds me of a previous discussion of tab stops for some reason. I feel like saying "here's a nickel, kid... buy yourself a decent text editor", but that's a bit rude. More nicely: It's not the programming language's job to take up the slack where your specific text editor is lagging, especially when I can name about half a dozen editors off the top of my head which can handle multiple files perfectly well.
I believe that our 21st century should finally forsake the old concept of file, as we see it now. A module is an entry in a database.
Be careful, lest you end up with a multiple maintenance problem. The reason why text files haven't gone the way of punched cards yet is that they're uniform and simple, and they're easy from a management point of view (one text file is one work assignment to a programmer in a team).
We have already separate 'interface files'...
...which are automatically generated. Cheers, Andrew Bromage
participants (5)
-
ajb@spamcop.net
-
Andrei de A. Formiga
-
Iavor S. Diatchki
-
Jerzy Karczmarczuk
-
Jon Fairbairn