_______________________________________________Dear all,
I would like to bring our own Richard Eisenberg’s proposal, #283: Local modules, to your attention.
https://github.com/ghc-proposals/ghc-proposals/pull/283The proposal is an attempt at solving the long debated issue that we can’t export qualified names out of a module (e.g. we may have to repeat
import qualified Data.Map as Map
andimport qualified Data.Set as Set
in every module in a project, rather than simply callingimport MyPrelude
which would take care of both and more), to improve scope management, and sharing names between types in the same files, while making namespaces more convenient to use in the process.It’s a pretty ambitious proposal, with quite a few interlocking pieces. Yet, in my opinion, they fit pretty well together. And I’m, as a potential consumer, very enthusiastic about it.
Some highlight (though do read the whole thing):
- We can define modules inside of other modules, with the syntax
module Foo (some, optional, exports) where …
- Like in the rest of Haskell, modules are no more than namespaces. Therefore you can open two
module Foo
, it will just merge the names in them- Values in local modules can be referred to, qualified, in the encompassing module
- Local modules can be exported, importing them will import the name as qualified
- A new
import module Foo
statement can be used inlet
andwhere
clauses, it brings everything of the formFoo.x
into scope unqualified for the scope of thelet
orwhere
Additionally, there is a small point that is not integral to the rest of the proposal, where defining, say, a type
data T = A | B
Would create a local module named
T
, such that the constructors could be referred to asT.A
andT.B
. I mention it separately, because it causes the only (small) backward incompatibility (that is Haskell 2010 programs which stop compiling when you turn on-XLocalModules
).I’m rather in favour of keeping it in, but it’s worth mentioning.
I pretty much want all of these features in my daily programming, so, as I said above, I’m very enthusiastic for all of this. And I’m pretty happy with the realisation. Hence my recommending acceptance.
/Arnaud
ghc-steering-committee mailing list
ghc-steering-committee@haskell.org
https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee