wiki:ShorterImportSyntax

Version 3 (modified by simonpj, 4 years ago) (diff)

--

Shorter import syntax

This page describes a proposed variant of Haskell's import declarations.

Trac ticket is #10478.

Link to discussions on

  • Haskell cafe discussion thread
  • Analysis of public code to characterize how common the confusing case would be months ago.

Specification

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.

In the language spec,

impdecl	→	import [qualified] modid [as modid] [impspec]

This grammar leaves out things like package imports and source imports, so I'm not sure if you want me to provide one grammar for all of them. For ShortImports, the grammar is,

impdecl -> import modid impspec as modid 

Examples

...