Multiple imports on a single line

Cale Gibbard cgibbard at gmail.com
Wed Feb 1 20:21:08 UTC 2017


The main annoying thing in import lists for me at the moment is the
proliferation of modules which one would like to import both qualified
under some alias and to import a handful of names unqualified (especially
infix functions and types). It would be nice if rather than

import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Sequence as S
import Data.Sequence (Seq, ViewR(..), ViewL(..), (<|), (|>))

we could instead have some variation like:

import Data.Map qualified as Map, (Map)
import Data.Sequence qualified as S, (Seq, ViewR(..), ViewL(..), (<|),
(|>))

I'm thinking something along the lines of the following:

*impdecl* -> import *modid impspec_1, impspec_2, ..., impspec_*n (n >= 0)
*impspec* -> ( *import*_1, ..., *import*_n [,] ) [*impqual*] (n >= 0)
         | *impqual*
*impqual* -> [qualified] as *modid* [*imphiding*]
         | *imphiding*
*imphiding* -> hiding (*import*_1, ..., *import*_n [,] ) (n >= 0)

I haven't thought particularly hard about this BNF, though hopefully it
gets across my idea. You'd also certainly want to mix in support (perhaps
with deprecation?) for the existing syntax which places the 'qualified'
before the module identifier, even though I've personally always found that
awkward, as it makes imports hard to read and sort.

The other thing which would greatly ameliorate the annoyance with import
lists would be the ability to import and then re-export modules in a way
that retains the manner in which things were qualified. So one could, if
one wanted, have a module which imports things like Map, Set, (lazy and
strict) Text, (lazy and strict) ByteString, etc. re-exported qualified the
way one wants, and then import that from the other modules in the project.

On Wed, Feb 1, 2017, 10:36 Francesco Ariis <fa-ml at ariis.it> wrote:

On Wed, Feb 01, 2017 at 04:18:13PM +0200, Vassil Ognyanov Keremidchiev
wrote:
> Hello!
>
> What do you think about an idea to have multiple imports on a single line,
> like:
>
> module MyApp where
> import Data.Text, Data.Foldable, Control.Concurrent
> ...

Hello Vassil,
  how would qualified/as work?
Would import statement like this:

    import Data.Text, qualified Data.Foldable as F, Control.Concurrent

be allowed?

_______________________________________________
Haskell-prime mailing list
Haskell-prime at haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-prime/attachments/20170201/f8b15717/attachment.html>


More information about the Haskell-prime mailing list