[Haskell-cafe] Proposal: Shorter Import Syntax

Anthony Cowley acowley at seas.upenn.edu
Wed Jun 3 19:07:45 UTC 2015


On Wed, Jun 3, 2015 at 2:45 PM, Kosyrev Serge
<_deepfire at feelingofgreen.ru> wrote:
> amindfv at gmail.com writes:
>> I'd be +1 provided we can write e.g.:
>>
>> import Data.Map (Map) as M (fromList)
>>
>> And then we'd get only the Map type and M.fromList
>
> Then wouldn't it also make sense to also:
>
>   1. eliminate the arguably confusing double-import through as-without-qualified:
>
>        import FQMN as M .. (which imports the exportlist of FQMN twice)
>
>      Does a lot of code use that?  Is this a good practice?  Do we want
>      to encourage this kind of usage?
>
>   2. and take advantage of the reduced complexity by implying
>      "qualified", wheneved "as" is present, by replacing:
>
>        import qualified FQMN as M …
>
>      with
>
>        import FQMN as M …
>
>   3. effectively drop the "qualified" keyword from use (can be done lazily)
>
> It would break things, though.
>

This (2) is what I would want to do, too, ideally. However, the
breakage really makes it inviable.

I tried to quantify the use of the other syntax in another email. I
grepped through the source of all the packages in the Stackage Nightly
package set and found that less 0.3% of imports use that syntax. It's
a small number, but it's not zero, so the breakage would be
unacceptable. However, I do think the number is small enough the
potential confusion due to syntax similarity is not a huge concern,
but that's a subjective anticipation of a possible future and some
people will disagree.

Anthony


More information about the Haskell-Cafe mailing list