summaryrefslogtreecommitdiff
path: root/docs/users_guide/exts/import_qualified_post.rst
blob: a9b0b6acca2facdd46691a2cd8ef6be8ec536997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.. _importqualifiedpost:

Writing qualified in postpositive position
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. extension:: ImportQualifiedPost
    :shortdesc: ``ImportQualifiedPost`` allows the syntax ``import M qualified``

    :since: 8.10.1

    ``ImportQualifiedPost`` allows the syntax ``import M qualified``, that is, to annotate a module as qualified by writing ``qualified`` after the module name.

To import a qualified module usually you must specify ``qualified`` in prepositive position : ``import qualified M``. This often leads to a "hanging indent" (which is automatically inserted by some autoformatters and common in many code bases. For example:

.. code-block::  none

 import qualified A
 import           B
 import           C

The ``ImportQualifiedPost`` extension allows ``qualified`` to appear in postpositive position : ``import M qualified``. With this extension enabled, one can write:

.. code-block:: none

   import A qualified
   import B
   import C

It is an error if ``qualified`` appears in both pre and postpositive positions.

The warning ``-Wprepositive-qualified-syntax`` (off by default) reports on any occurrences of imports annotated ``qualified`` using prepositive syntax.