From varosi at gmail.com Wed Feb 1 14:18:13 2017 From: varosi at gmail.com (Vassil Ognyanov Keremidchiev) Date: Wed, 1 Feb 2017 16:18:13 +0200 Subject: Multiple imports on a single line Message-ID: 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 ... That way we could write more concise and short code as Haskell promises. This will be useful for small programs like scripts, small tools, tutorials, examples, etc. Best regards, Vassil Keremidchiev -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Wed Feb 1 15:34:57 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Wed, 1 Feb 2017 16:34:57 +0100 Subject: Multiple imports on a single line In-Reply-To: References: Message-ID: <20170201153457.GA11112@casa.casa> 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? From carter.schonwald at gmail.com Wed Feb 1 19:29:52 2017 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Wed, 1 Feb 2017 14:29:52 -0500 Subject: Multiple imports on a single line In-Reply-To: <20170201153457.GA11112@casa.casa> References: <20170201153457.GA11112@casa.casa> Message-ID: likewise, why not use semicolon? per se we already can do mulitple lines on a single line via semicolon :) On Wed, Feb 1, 2017 at 10:34 AM, Francesco Ariis 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: From Coeus at gmx.de Wed Feb 1 19:51:25 2017 From: Coeus at gmx.de (Marc Ziegert) Date: Wed, 1 Feb 2017 20:51:25 +0100 Subject: Aw: Re: Multiple imports on a single line In-Reply-To: <20170201153457.GA11112@casa.casa> References: , <20170201153457.GA11112@casa.casa> Message-ID: I like this idea. How about some more syntactic sugar? {-# LANGUAGE ImportSugar #-} import [Data.[Text, Foldable q-as F, Vector (Vector), Vector q-as V hiding (Vector)], Control.Concurrent, Data.List q (sum)] - tree structure, one import per leaf - prefix qualified -> postfix q - qualified/as -> q-as or q as or q/as or qas > Gesendet: Mittwoch, 01. Februar 2017 um 16:34 Uhr > Von: "Francesco Ariis" > An: haskell-prime at haskell.org > Betreff: Re: Multiple imports on a single line > > 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 > From cgibbard at gmail.com Wed Feb 1 20:21:08 2017 From: cgibbard at gmail.com (Cale Gibbard) Date: Wed, 01 Feb 2017 20:21:08 +0000 Subject: Multiple imports on a single line In-Reply-To: <20170201153457.GA11112@casa.casa> References: <20170201153457.GA11112@casa.casa> Message-ID: 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 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: From svenpanne at gmail.com Wed Feb 1 20:22:58 2017 From: svenpanne at gmail.com (Sven Panne) Date: Wed, 1 Feb 2017 21:22:58 +0100 Subject: Multiple imports on a single line In-Reply-To: References: <20170201153457.GA11112@casa.casa> Message-ID: 2017-02-01 20:51 GMT+01:00 Marc Ziegert : > [...] How about some more syntactic sugar? > > {-# LANGUAGE ImportSugar #-} > import [Data.[Text, Foldable q-as F, Vector (Vector), Vector q-as V hiding > (Vector)], Control.Concurrent, Data.List q (sum)] > [...] o_O I am really not sure if this is a serious proposal or just some funny remark, taking the initial proposal to an extreme: Is it really a good idea to condense something so heavily? I don't think so, deciphering the above import probably takes you multiple times the effort to read the plain old simple imports spanning several (easy) lines. Quoting Martin Fowler: *"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." *This simply looks too ingenious, so http://wiki.c2.com/?KillYourDarlings probably applies, and so does https://en.wikipedia.org/wiki/KISS_principle. Apart from the incomprehensibility for humans: For every seemingly "easy" syntactic extension, the cost for related tools like IDEs etc. has to be considered. Have fun e.g. extending syntax highlighting to handle such stuff. And finally: What problem are we actually trying to solve? From my POV, imports are largely irrelevant when reading code, you just skim over them to get an idea, and then forget about them/fold them in your editor/mechanically clean them up via your IDE/etc. The only time they are really important is when something goes wrong and/or name resolution is not obvious. And exactly at that time, one really needs simple stuff to look at, not a Perl-like one-liner. But as I said, that's just my opinion... -------------- next part -------------- An HTML attachment was scrubbed... URL: From malcolm.wallace at me.com Wed Feb 1 21:23:20 2017 From: malcolm.wallace at me.com (Malcolm Wallace) Date: Wed, 01 Feb 2017 21:23:20 +0000 Subject: Multiple imports on a single line In-Reply-To: References: Message-ID: You can already write this, with only a tiny bit of syntax: module MyApp where import Data.Text; import Data.Foldable; import Control.Concurrent Whether it is good style is another matter, but all compilers will certainly accept it. Regards, Malcolm On 1 Feb 2017, at 14:18, 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 > ... > > That way we could write more concise and short code as Haskell promises. This will be useful for small programs like scripts, small tools, tutorials, examples, etc. > > Best regards, > Vassil Keremidchiev > _______________________________________________ > 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: From varosi at gmail.com Wed Feb 1 21:39:43 2017 From: varosi at gmail.com (Vassil Ognyanov Keremidchiev) Date: Wed, 1 Feb 2017 23:39:43 +0200 Subject: Multiple imports on a single line In-Reply-To: References: Message-ID: Yes, but it could be a bit more denser without so much repetition of "import", like: import Data.Text, qualified Data.Map as M, qualified Vector as V hiding (Vector) i.e. the same as current situation, but allow for multiple imports for the same word "import" comma separated. What do you think? The difference in syntax is not so much different, than just allowing commas. 2017-02-01 23:23 GMT+02:00 Malcolm Wallace : > You can already write this, with only a tiny bit of syntax: > > module MyApp where > import Data.Text; import Data.Foldable; import Control.Concurrent > > Whether it is good style is another matter, but all compilers will > certainly accept it. > > Regards, > Malcolm > > > On 1 Feb 2017, at 14:18, 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 > ... > > > That way we could write more concise and short code as Haskell promises. > This will be useful for small programs like scripts, small tools, > tutorials, examples, etc. > > Best regards, > Vassil Keremidchiev > _______________________________________________ > 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: From svenpanne at gmail.com Thu Feb 2 07:41:49 2017 From: svenpanne at gmail.com (Sven Panne) Date: Thu, 2 Feb 2017 08:41:49 +0100 Subject: Multiple imports on a single line In-Reply-To: References: Message-ID: 2017-02-01 22:39 GMT+01:00 Vassil Ognyanov Keremidchiev : > Yes, but it could be a bit more denser without so much repetition of > "import", like: > > import Data.Text, qualified Data.Map as M, qualified Vector as V hiding > (Vector) > > i.e. the same as current situation, but allow for multiple imports for the > same word "import" comma separated. What do you think? The difference in > syntax is not so much different, than just allowing commas. > I think this is worse than separate imports, each on a separate line. The Python people have even put something like this into a PEP: https://www.python.org/dev/peps/pep-0008/#imports This is for a very good reason: The one-liners have very few visual hints for the reader to comprehend it quickly. So even if Haskell allowed this comma-separated chain of imports, code containing it probably wouldn't survive a code review in most companies, where maintainability is the prime goal. I often see a confusion between greater expresiveness (good goal) and having to type less (largely irrelevant goal). By all means make the module system more expressive, but try to avoid "clever" things for convenience. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jon.fairbairn at cl.cam.ac.uk Thu Feb 2 10:07:52 2017 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Thu, 02 Feb 2017 10:07:52 +0000 Subject: Multiple imports on a single line References: Message-ID: Sven Panne writes: > I often see a confusion between greater expresiveness (good goal) and > having to type less (largely irrelevant goal). By all means make the module > system more expressive, but try to avoid "clever" things for convenience. +1 -- Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk From doug at cs.dartmouth.edu Thu Feb 2 14:52:33 2017 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Thu, 02 Feb 2017 09:52:33 -0500 Subject: Multiple imports on a single line Message-ID: <201702021452.v12EqXW3024164@coolidge.cs.Dartmouth.EDU> > I often see a confusion between greater expresiveness (good goal) and > having to type less (largely irrelevant goal). By all means make the module > system more expressive, but try to avoid "clever" things for convenience. To expand upon this principle a bit, syntactic sugar that promises to save O(1) typing in an n-line module is suspect; that which might save O(n) is more promising. Doug From varosi at gmail.com Thu Feb 2 21:36:14 2017 From: varosi at gmail.com (Vassil Ognyanov Keremidchiev) Date: Thu, 2 Feb 2017 23:36:14 +0200 Subject: Multiple imports on a single line In-Reply-To: <201702021452.v12EqXW3024164@coolidge.cs.Dartmouth.EDU> References: <201702021452.v12EqXW3024164@coolidge.cs.Dartmouth.EDU> Message-ID: So it's O(N) -> O(1) where N is a number of lines/imports. But you're right for the readiness. I'm convinced! 2017-02-02 16:52 GMT+02:00 Doug McIlroy : > > I often see a confusion between greater expresiveness (good goal) and > > having to type less (largely irrelevant goal). By all means make the > module > > system more expressive, but try to avoid "clever" things for convenience. > > To expand upon this principle a bit, syntactic sugar that promises to save > O(1) > typing in an n-line module is suspect; that which might save O(n) is more > promising. > > Doug > > > _______________________________________________ > 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: