Opened 5 years ago

Closed 4 years ago

#9977 closed feature request (wontfix)

Nicer imports

Reported by: tolysz Owned by:
Priority: lowest Milestone:
Component: Compiler (Parser) Version: 7.11
Keywords: imports Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Hi, I wonder if we could have

import
  Data
    A
    B (ba, bb, bc)
    C  as C
    C1 as C1 (ca,cb,cc)
    D qualified
    E as E qualified
    F as F qualified (fa, fb, fc)
  Libs.Other

--  Data.E qualified as E -- both valid
--  Data.F qualified as F (fa, fb, fc)

to desugar to

import           Data.A
import           Data.B (ba, bb, bc)
import           Data.C as C
import qualified Data.D
import qualified Data.E as E
import qualified Data.F as F (fa, fb, fc)
import Libs.Other

so we could make syntax more dry? What it does if there is indentation it uses previous levels as prefix

Change History (4)

comment:1 Changed 5 years ago by rwbarton

In your example, how would you distinguish whether or not you intend to import the module Data? Or more realistically, how do I import both Data.ByteString and Data.ByteString.Lazy without repeating ByteString?

comment:2 Changed 5 years ago by tolysz

import
  Data.ByteString
      @
      Lazy
import
  Data.ByteString {@, Lazy}

import Data.ByteString {@, Lazy}

You got me, there needs to be a symbol for indicating current node, and not sure which would be the best one @ here is just an example. Curly brackets to de-sugaring to indentation would help as well :)

comment:3 Changed 4 years ago by ezyang

Milestone:

Unfortunately, this proposal is completely incompatible with how layout rule works in Haskell today, which is that is triggered on a few special keywords. There is nothing of the sort here, so you would have to enforce layout through an alternate mechanism. I think it's unlikely that we'd accept this proposal.

comment:4 Changed 4 years ago by thomie

Resolution: wontfix
Status: newclosed

Try to get support for this on one of the mailing lists first. See also: WorkingConventions/AddingFeatures.

Note: See TracTickets for help on using tickets.