File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,35 @@ The module ``A`` will export the name ``a``, as well as any public or
179179abstract names in module ``C ``, but will not re-export anything from
180180module ``B ``.
181181
182+ Renaming imports
183+ ----------------
184+
185+ Sometimes it is convenient to be able to access the names in another module
186+ via a different namespace (typically, a shorter one). For this, you can
187+ use `import...as `. For example:
188+
189+ ::
190+
191+ module A
192+
193+ import Data.List as L
194+
195+ This module ``A `` has access to the exported names from module ``Data.List ``,
196+ but can also explicitly access them via the module name ``L ``. ``import...as ``
197+ can also be combined with ``import public `` to create a module which exports
198+ a larger API from other sub-modules:
199+
200+ ::
201+
202+ module Books
203+
204+ import Books.Hardback as Books
205+ import Books.Comic as Books
206+
207+ Here, any module which imports ``Books `` will have access to the exported
208+ interfaces of ``Books.Hardback `` and ``Books.Comic `` both under the namespace
209+ ``Books ``.
210+
182211Explicit Namespaces
183212===================
184213
You can’t perform that action at this time.
0 commit comments