
[narrowing to libraries] | > I think most of you know that GHC 6.6 made (IHMO) a significant step | > forward, by allowing a program to contain multiple modules with the same | > name, if they are from different packages. That means that package | > authors can choose module names freely, rather than worry about | > accidentally colliding with other packages. | | I think this is true only in a very technical sense. I fear that in | practice, library authors will go to great lengths to avoid such | overlapping module names, because introducing them will cause too much | difficulties for library users. The only way to make halfway sure that this | doesn't happen is to use (fixed) module hierarchy prefixes containing (more | or less) the package name, as in "Text.ParserCombinators.Parsec", even | though technically they aren't forced to do so. Why would authors go to great lengths to avoid overlapping module names? The only possible penalty of overlap is that it's a bit awkward to import modules with the same name into the same module. But that's always fixable by making a two-line impedance-matching module. I feel I'm missing your point. | I see, however, one point with Frederik's proposal that isn't clear to me: | | Assume library A uses library B. Then, presumably, lib A must chose a mount | point for its use of lib B. Now imagine a program P wants to use lib A as | well as directly import some module from lib B. Is P now free to give lib B | its own mount point, independent of the one that was chosen by lib A? Oh yes, of course! The mount point simply affects the name space seen by the import declarations in a particular compilation. There is no implementation difficulty here. | > That still leaves an open question, not resolved by GHC 6.6: what to do | > if you want to import module M from two different packages into the same | > module? | | What if I want to import them into /different/ modules (which are | nevertheless part of the same package)? Can this be easily accomplished | with ghc-6.6? Yes, certainly. Suppose that package 'foo' and 'bar' both contain module M. Then you want to import foo.M into module X, and bar.M into module Y. Easy: just compile X with '-package foo' and Y with '-package bar'. The difficulty arises only if you want to import foo.M and bar.M into the *same* module. Indeed, the difference between Plan B and C (in the terminology of the GhcPackages page) is only whether you say ghc X.hs -package foo -package bar where module X import M from "foo" import M from "bar" or whether you say ghc -package foo@Foo -package bar@Bar X.hs where module X import Foo.M import Bar.M The two are really very close --- but the nuances are different and they are important. Simon