[ghc-steering-committee] #283: Local modules, recommendation: accept

Spiwack, Arnaud arnaud.spiwack at tweag.io
Wed Oct 14 14:08:03 UTC 2020


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/283

The 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 and import qualified Data.Set as Set in every
module in a project, rather than simply calling import 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 in let and where
   clauses, it brings everything of the form Foo.x into scope unqualified
   for the scope of the let or where

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 as T.A and T.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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20201014/f4ab9bf4/attachment.html>


More information about the ghc-steering-committee mailing list