[GHC] #10478: Shorter import syntax

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.10.1 Component: Compiler | Operating System: Unknown/Multiple Keywords: | Type of failure: None/Unknown Architecture: | Blocked By: Unknown/Multiple | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- It would be helpful to support a short syntax for importing unqualified identifiers while establishing a short qualified name. An example of the proposed syntax is, {{{#!hs import Data.Map (Map) as M }}} The desired semantics are that `Map` be imported unqualified, and `M` be defined as an alias for `Data.Map`. This replaces the existing convention of writing, {{{#!hs import Data.Map (Map) import qualified Data.Map as M }}} The proposed syntax is currently an error, I think, so adding support for it should not break anything. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by acowley): I had forgotten about the existing `import Data.Map as M` syntax. So this request, as it stands, is not backwards compatible. Nonetheless, a way of collapsing the two import lines into one would be appreciated. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Yuras): Note that currently the next is allowed: {{{#!haskell import Data.Map as M (Map) }}} Different semantics based on order of parens and `as` is too ambiguous and hard to remember IMO. Also, the existing convention to import data type unqualified and the rest qualified is some kind of a hack working around lack of nested namespaces. In the ideal world `Data.Map` should export functions qualified. Like the next: {{{#!haskell module Data.Map (Map, namespace Map) where data Map = ... namespace Map where length :: Map -> Int length ... }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): I'm in favor of abbreviating the syntax in this common scenario, but I don't like your choice of syntax, I'm afraid. It would give {{{ import Data.Map (Map) as M -- (1) }}} a very different meaning from {{{ import Data.Map as M (Map) -- (2) }}} (1) imports all of `Data.Map`, qualified with the alias `M`, and imports the name `Map` unqualified. (2) imports only the name `Map` (unqualified) while also aliasing `Data.Map`. Having these two coexist seems like we're asking users to be confused. What about {{{ import Data.Map (Map) qualified as M * }}} ? The general schema, which replaces the current syntax. This schema does not permit some current syntax, but it would be easy to extend it to be backward-compatible. I've chosen not to for this presentation to avoid clutter. {{{ import_statement ::= 'import' module_name maybe_name_list import_specifiers module_name ::= ... maybe_name_list ::= name_list | <empty> name_list ::= '(' names ')' | '*' import_specifiers ::= <empty> | import_specifier import_specifiers import_specifier ::= 'hiding' name_list | qualified_spec name_list qualified_spec ::= 'qualified' | 'qualified' 'as' name }}} The top-level `maybe_name_list` would list all unqualified imports. If it is omitted, and there are no `qualified_spec`s, then all names would be imported unqualified. If it is omitted and there are one or more `qualified_spec`s, then no names would be imported unqualified. Each `import_specifier` either adds qualified names (perhaps under a module synonym) or removes names. Removing names with `hiding` removes those names from the `qualified_spec` (or top-level `maybe_name_list`) immediately preceding the `hiding`. The special `name_list` `*` (note that it is ''not'' in parentheses, to avoid ambiguity) means "all names". This schema allows one import statement to import a mix of qualified and unqualified names, and even allows using different module synonyms for different sets of qualified names. The legacy `import` syntax could desugar to this form, which seems strictly more expressive. For example: {{{ import qualified Foo --> import Foo qualified * import qualified Bar as B --> import Bar qualified as B * import Baz hiding (wurble) --> import Baz hiding (wurble) }}} Thoughts? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by lelf): * cc: lelf (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Rufflewind): Why not use `(..)` instead of `*`? It seems more consistent with Haskell's current syntax. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): Replying to [comment:5 Rufflewind]:
Why not use `(..)` instead of `*`? It seems more consistent with Haskell's current syntax.
Sold. I like this much more than `*`. It was also suggested that `(..)` could be omitted if it were going to be the last item on the line. I'm happy with that suggestion, too. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by s9gf4ult): Why not?
import qualified Data.Map (Map) as M
While it is qualified import it should have keyword "qualified" to specify that explicitly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Rufflewind): Replying to [comment:7 s9gf4ult]:
Why not?
import qualified Data.Map (Map) as M
While it is qualified import it should have keyword "qualified" to specify that explicitly.
The `qualified` applies to `M` but not to `(Map)`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by s9gf4ult):
The `qualified` applies to `M` but not to `(Map)`.
Yes, but this syntax still looks more logical than without "qaulified". It is not obvious to see something like
import Data.Map (Map) as M
And have module Data.Map imported qualified as M. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by acowley): I don't think a desire to keep the `qualified` word is more logical or obvious than any other option. I can't think of another programming language that uses the `qualified` keyword. Agda uses `import M as N` to create a qualified alias. Python imports qualified by default. But this is Haskell, so we should consider how Haskell is used. If you grep over the source of all packages in the Stackage package set, you will find that `import` statements that use the `as` keyword are `qualified` 10x more than unqualified. If you focus on the specific syntax, `import Foo as F(bar)`, it is used in less than 0.3% of all import statements. So we are loading by far the more common usage with extra syntax. I suggest a way of reading import statements as "import ModuleName (unqualifiedImports)" If you want to use qualified names, all of that information is given by appending a suffix to the import statement beginning with the `as` keyword. This is certainly ''new'' syntax, but I have yet to see any quantifiable argument that it is less logical or undesired (see the support for the proposal linked from the haskell-cafe thread). Also note that the proposal will not break ''anything'': if you find `qualified` easier to read, then you can continue to use it. If nobody uses the new syntax because it is hard to understand, then nobody will suffer. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Changes (by thomie): * differential: => Phab:D1238 Comment: Other discussions of this proposal: * https://mail.haskell.org/pipermail/haskell-cafe/2015-June/119942.html * https://www.reddit.com/r/haskell/comments/38vsef/proposal_shorter_import_syn... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by thomie): Here is an overview for two of the proposals listed on this ticket. Please inform me of any mistakes there might be, and I will edit this comment. I'm using the variant of goldfire's proposal with `(..)` instead of `*`, and where `(..) ` at the end of the line can be omitted. @goldfire: I understand your proposal would (also) be fully backward compatible. Please tell me on which rows you would recommend to use the old syntax. And maybe there's a useful trick only your proposal supports? Suppose the `module A` exports `x` and `y`. * Without a module alias: ||= # =||= Haskell 2010 =||= Proposal acowey || Proposal goldfire =||= Brings into scope =|| || 1 || import A || **import A** || **import A (..) qualified** || x, y, A.x, A.y || || 2 || import A (x) || **import A (x)** || **import A (..) qualified (x)** || x, A.x || || 3 || import qualified A || **import A () as A** || **import A qualified** || A.x, A.y || || 4 || import qualified A (x) || **import A () as A (x)** || **import A qualified (x)** || A.x || * With a module alias: ||= # =||= Haskell 2010 =||= Proposal acowey || Proposal goldfire =||= Brings into scope =|| || 5 || import A as B || **import A as B** || **import A (..) qualified as B** || x, y, B.x, B.y || || 6 || import A as B (x) || **import A as B (x)** || **import A (x) qualified as B (x)** || x, B.x || || 7 || import qualified A as B || **import A () as B** || **import A qualified as B** || B.x, B.y || || 8 || import qualified A as B (x) || **import A () as B (x)** || **import A qualified as B (x)** || B.x || * The real deal: ||= # =||- Haskell 2010 =||= Proposal acowey || Proposal goldfire =||= Brings into scope =|| || 9 || import A (x); || **import A (x) as B** || **import A (x) qualified as B** || x, B.x, B.y || || || import qualified A as B || || 10 || //(impossible)// || **import A (x) as X ()** || **import A (x) qualified ()** || x || Potentially confusing things about these proposals, assuming full backward compatibility: ||= proposal =||= H2010 syntax =||= new syntax =||= Why confusing? =|| ||= acowley =|| **import A as B (x)** || **import A (x) as B** || look similar, do different things || ||= goldfire =|| **import qualified A as B (x)** || **import A (x) qualified as B** || look similar, do different things || ||= goldfire =|| **import qualified A** || **import A qualified** || look different, do the same thing || -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by goldfire): Perhaps my proposal was not clearly stated. I have modified the examples below to support my intent. If you see an error in the proposal, please do let me know! My changes affect the first block and the very last line.
Suppose the `module A` exports `x` and `y`.
* Without a module alias: ||= # =||= Haskell 2010 =||= Proposal acowley =||= Proposal goldfire
=||= Brings into scope =||
||= 1 =|| import A || **import A** || **import A** || x, y, A.x, A.y || ||= 2 =|| import A (x) || **import A (x)** || **import A (x)** || x, A.x || ||= 3 =|| import qualified A || **import A () as A** || **import A qualified** || A.x, A.y || ||= 4 =|| import qualified A (x) || **import A () as A (x)** || **import A qualified (x)** || A.x ||
* With a module alias: ||= # =||= Haskell 2010 =||= Proposal acowley =||= Proposal goldfire =||= Brings into scope =|| ||= 5 =|| import A as B || **import A as B** || **import A (..) qualified as B** || x, y, B.x, B.y || ||= 6 =|| import A as B (x) || **import A as B (x)** || **import A (x) qualified as B (x)** || x, B.x || ||= 7 =|| import qualified A as B || **import A () as B** || **import A qualified as B** || B.x, B.y || ||= 8 =|| import qualified A as B (x) || **import A () as B (x)** || **import A qualified as B (x)** || B.x ||
* The real deal: ||= # =||= Haskell 2010 =||= Proposal acowley =||= Proposal goldfire =||= Brings into scope =|| ||= 9 =|| import A (x); || **import A (x) as B** || **import A (x) qualified as B** || x, B.x, B.y || || || import qualified A as B || ||= 10 =|| //(impossible)// || **import A (x) as X ()** || **import A (x) qualified ()** || x ||
Potentially confusing things about these proposals, assuming full backward compatibility:
||= proposal =||= H2010 syntax =||= new syntax =||= Why confusing? =|| ||= acowley =|| **import A as B (x)** || **import A (x) as B** || look similar, do different things || ||= goldfire =|| **import qualified A as B (x)** || **import A (x) qualified as B** || look similar, do different things || ||= goldfire =|| **import qualified A** || **import A qualified** || look similar, do different things ||
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by thomie): What is the difference between `import qualified A` and `import A qualified` (row 3)? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by goldfire): Replying to [comment:14 thomie]:
What is the difference between `import qualified A` and `import A qualified` (row 3)?
You're right. Those are the same. I've edited it all to clarify. `import qualified A (..)` brings `A.x` and `A.y` into scope. `import A (..) qualified` brings `x`, `y`, `A.x`, and `A.y` into scope. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by acowley): Replying to [comment:12 thomie]:
Potentially confusing things about these proposals, assuming full backward compatibility:
||= proposal =||= H2010 syntax =||= new syntax =||= Why confusing? =|| ||= acowley =|| **import A as B (x)** || **import A (x) as B** || look similar, do different things ||
Just to chime in to confirm that this is the most ripe for confusion part of the proposal. No semantics of working code change with the extension enabled, but this point of confusion is introduced. For context, the syntax `import A as B (x)` is used in 0.3% of all `import` statements over all the code in the Stackage package set. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by thomie): acowley: you could avoid the confusion by saying `import A (x) as B (..)`. But I'm not sure that's worth it. Summary of the previous [https://mail.haskell.org/pipermail/haskell- cafe/2015-June/119942.html mailinglist discussion] and [https://www.reddit.com/r/haskell/comments/38vsef/proposal_shorter_import_syn... reddit] thread: * A lot (15?) of people on the mailinglist were in favour of acowley's proposal, or at least for some form of shorter import syntax. * Only [https://mail.haskell.org/pipermail/haskell- cafe/2015-June/119958.html one] person was specifically in favour of goldfire's proposal. I think this low number had more to do with the proposal not being presented very clearly than anything else, given how similar the two proposals are. * A few people were (strongly) against acowley's proposal, all citing [https://mail.haskell.org/pipermail/haskell-cafe/2015-June/119982.html Richard O'Keefe's mail]. * [https://www.reddit.com/r/haskell/comments/38vsef/proposal_shorter_import_syn... reddit] seemed firmly against acowley's proposal as well (the top comment has 12 votes and starts with "-1"). This is the reason I think we should proceed carefully here. I don't think this is going to go anywhere without someone writing a [https://ghc.haskell.org/trac/ghc/wiki/Proposal proposal page] on the wiki, with specifications of the 2 options and the above table, and then having another round of discussion on the mailinglist. If one of you could get behind the other person's proposal, that would make things easier as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by thomie): More explicitly, @acowley: * Could you please start a `Proposal/ShortImports` wiki page with a specification of your language extension? * What is your opinion on goldfire's alternative proposal (see comment:3 and comment:13)? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by acowley): No, I need to stop this exercise in futility. I canvassed IRC and received broad support, I canvassed on twitter and received broad support, I canvassed on haskell-cafe and received mixed support. I did the work of analyzing public code to characterize how common the confusing case would be months ago. This is support from nearly a hundred people for a minor language extension that breaks absolutely nothing. I have never seen so much voting for a GHC language extension. The code is now available with tests and documentation updates. Despite the small text of the original ticket above, it has been mis- characterized as breaking existing code time and time again, even today on the Phabricator discussion. You have now linked to a reddit post on what is actually an alternate proposal (`andAs`). When I follow your link, I see a +10 post saying -1 linking to sarcastic posts arguing that syntactic changes are unacceptable from an individual who cheers for (::Type) syntax, I see a +9 post that's +1 for shorter syntax, and a +8 for shorter syntax with my proposal (again, on a thread for an ''alternate'' proposal). I think @goldfire's proposal, though well intentioned, largely misses the point of offering more concise syntax, and includes more confusing cases. The stark lack of support it has received despite being from a regular GHC developer ought to be telling, yet is here dismissed as an odd coincidence. The patch is available. It does what I have written here, in the commit messages, and in the updated GHC documentation. The last time this went through the mailing list I received abusive mails for days, followed by apologies for the community's behavior for even more days. I am not doing that again. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by simonpj): @acowley, is there a ''specification'' somewhere that I can read? I'm sorry if I missed it. To be concrete, what new wording would be needed in the [https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-1000005... Export lists] and [https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-1010005... Import declarations] sections of the language definition? thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by acowley): Sure, {{{ import modid maybeImpspec maybeAs }}} Semantics are the same as existing imports unless both an `impspec` (i.e. a parenthesised list of identifiers optionally prefixed with the `hiding` keyword) and an `as` (e.g. `as M`) are present. In such a case, all identifiers exported by `modid` are accessible behind the prefix given by the `as`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:21 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

In such a case, all identifiers exported by modid are accessible behind
#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by simonpj): Thanks. I have started a wiki page for you, [wiki:ShorterImportSyntax]. Omitting package imports and source imports, the [https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-1010005... import declaration grammar] is {{{ impdecl → import [qualified] modid [as modid] [impspec] }}} What I can't figure out from the above is whether you propose any ''change'' in grammar. Are you saying that switching the order of `as modid` and `impspec` makes the difference? If so could you perhaps just give the new grammar on the wiki page? the prefix given by the as How does that differ from this: {{{ import M as N }}} I'm not being picky; I'm just genuinely trying to understand what you propose but (like all future GHC users) without reading the long discussion that led up to it. Rather than replying to me inline here, it'd be great to update the wiki page to be as precise as you possibly can, add some examples, add links to the discussion and analysis you have done. That way the wiki becomes a standalone description of the proposed feature. Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:22 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1238 -------------------------------------+------------------------------------- Comment (by acowley): I'm probably missing something here: we both pasted the exact same line from the spec, and I offered the changed version, {{{ impdecl -> import modid impspec as modid }}} This is different from the spec in that `qualified` does not appear, and the `impspec` has moved. Further, neither the `impspec` nor the `as modid` are optional if you want to trigger the new behavior. They both must appear to invoke `ShortImports` behavior. The proposed syntax is syntactically invalid in Haskell2010. I've included on the wiki several ways of writing the grammar in an attempt to find one that can communicate. The patch itself already works and is smaller than any of these posts, so perhaps the code would be clearer if one is used to happy syntax. I've updated the wiki page to come at these issues from every angle I could think of. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:23 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10478: Shorter import syntax -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1238 Wiki Page: | -------------------------------------+------------------------------------- Changes (by waern): * cc: david.waern@… (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10478#comment:24 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC