
#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