Feature Request : Qualified module exports
Erik de Castro Lopo
mle+hs at mega-nerd.com
Mon Jul 8 14:05:09 CEST 2013
David Luposchainsky wrote:
> I'm not sure this is such a good idea.
>
> Haskell's namespace system happens strictly during import - the importer
> chooses what name to use, and a module has no influence on how it will
> be referred to by other modules.
>
> On the other side, there's the C++-like namespace system, where each
> function is defined as part of some namespace, leading to the
> "qualification" during export. In other words, if foo is defined in
> namespace bar, you will always have to refer to it as bar::foo.
>
> The proposal blurs the line between these two - a module can specify
> under what qualified name another module is imported.
Just about any language feature can be abused in some way. This proposal
can also be misused, but can be extremely beneficial in a number of very
common use cases.
There is a huge amount of existing code out there that does one or
more of the following two:
import qualified Data.ByteString.Char8 as BS8
import qualified Data.Text as T
with every module using those modules having the exact same two lines
of code. My code already has a custom Prelude which drops some dangerous
functions (head/tail etc) and adds types Text, ByteString and a couple
of my own functions. For my current project, qualified exports would
remove the above two lines from about 50 files.
If this feature was only enabled with a -XQualifiedModuleExports pragma,
would that decrease your objection?
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the ghc-devs
mailing list