summaryrefslogtreecommitdiff
path: root/docs/users_guide/exts/package_qualified_imports.rst
blob: d0e632307d8cea5361e03d4071fdd1667f13c5ad (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
34
35
.. _package-qualified-imports:

Package-qualified imports
~~~~~~~~~~~~~~~~~~~~~~~~~

.. extension:: PackageImports
    :shortdesc: Enable package-qualified imports.

    :since: 6.10.1

    Allow the use of package-qualified ``import`` syntax.

With the :extension:`PackageImports` extension, GHC allows import declarations to be
qualified by the package name that the module is intended to be imported
from. For example: ::

    import "network" Network.Socket

would import the module ``Network.Socket`` from the package ``network``
(any version). This may be used to disambiguate an import when the same
module is available from multiple packages, or is present in both the
current package being built and an external package.

The special package name ``this`` can be used to refer to the current
package being built.

.. note::
   You probably don't need to use this feature, it was added mainly so that we
   can build backwards-compatible versions of packages when APIs change. It can
   lead to fragile dependencies in the common case: modules occasionally move
   from one package to another, rendering any package-qualified imports broken.
   See also :ref:`package-thinning-and-renaming` for an alternative way of
   disambiguating between module names.