[Git][ghc/ghc][wip/int-index/imp-exp-whole-namespace] Update documentation
Vladislav Zavialov pushed to branch wip/int-index/imp-exp-whole-namespace at Glasgow Haskell Compiler / GHC Commits: 6aabe758 by Vladislav Zavialov at 2025-10-29T14:34:28+03:00 Update documentation - - - - - 3 changed files: - compiler/GHC/Hs/Basic.hs - docs/users_guide/9.16.1-notes.rst - docs/users_guide/exts/explicit_namespaces.rst Changes: ===================================== compiler/GHC/Hs/Basic.hs ===================================== @@ -67,24 +67,26 @@ instance Binary FixityDirection where -- -- * import/export items -- * fixity signatures --- * WARNINIG and DEPRECATED pragmas +-- * @WARNINIG@ and @DEPRECATED@ pragmas -- -- Examples: -- --- module M (data ..) where --- -- ↑ DataNamespaceSpecifier +-- @ +-- module M (data ..) where +-- -- ↑ DataNamespaceSpecifier -- --- import Data.Proxy (type ..) as T --- -- ↑ TypeNamespaceSpecifier +-- import Data.Proxy as T (type ..) +-- -- ↑ TypeNamespaceSpecifier -- --- {-# WARNING in "x-partial" data Head "don't use this pattern synonym" #-} --- -- ↑ DataNamespaceSpecifier +-- {-# WARNING in "x-partial" data Head "don't use this pattern synonym" #-} +-- -- ↑ DataNamespaceSpecifier -- --- {-# DEPRECATED type D "This type was deprecated" #-} --- -- ↑ TypeNamespaceSpecifier +-- {-# DEPRECATED type D "This type was deprecated" #-} +-- -- ↑ TypeNamespaceSpecifier -- --- infixr 6 data $ --- -- ↑ DataNamespaceSpecifier +-- infixr 6 data $ +-- -- ↑ DataNamespaceSpecifier +-- @ data NamespaceSpecifier = NoNamespaceSpecifier | TypeNamespaceSpecifier (EpToken "type") @@ -112,4 +114,4 @@ coveredByNamespaceSpecifier DataNamespaceSpecifier{} = isValNameSpace instance Outputable NamespaceSpecifier where ppr NoNamespaceSpecifier = empty ppr TypeNamespaceSpecifier{} = text "type" - ppr DataNamespaceSpecifier{} = text "data" \ No newline at end of file + ppr DataNamespaceSpecifier{} = text "data" ===================================== docs/users_guide/9.16.1-notes.rst ===================================== @@ -16,6 +16,9 @@ Language result, you may need to enable :extension:`DataKinds` in code that did not previously require it. +- The extension :extension:`ExplicitNamespaces` now allows namespace-specified + wildcards ``type ..`` and ``data ..`` in import and export lists. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/explicit_namespaces.rst ===================================== @@ -118,6 +118,36 @@ The ``pattern`` keyword does the same, with only a few differences: The ``data`` keyword is preferred over ``pattern`` in import/export lists unless there is a need to support older GHC versions. +Wildcards in import/export lists +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**Since:** GHC 9.16 + +Namespace-specified wildcards ``type ..`` and ``data ..`` may be used to import +all names in the corresponding namespace from a module: :: + + import M (type ..) -- imports all type and class constructors from M + import M (data ..) -- imports all data constructors and terms from M + +The primary intended use of this feature is in combination with module aliases, +allowing namespace disambiguation: :: + + import Data.Proxy as T (type ..) -- T.Proxy is unambiguously the type constructor + import Data.Proxy as D (data ..) -- D.Proxy is unambiguously the data constructor + +Using both wildcards ``import M (type .., data ..)`` is legal but redundant, as +it is equivalent to ``import M`` with no import list. + +Similarly, one may use wildcards in the export list of a module: :: + + module M (type .., f) where + -- exports all type and class constructors defined in M, + -- plus the function 'f' + +Using both wildcards ``module M (type .., data ..)`` is legal but redundant, as +it is equivalent to a whole module reexport ``module M (module M)``. + + Explicit namespaces in fixity declarations and warning/deprecation pragmas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6aabe75818dbcd05758e01e7f80626db... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6aabe75818dbcd05758e01e7f80626db... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Vladislav Zavialov (@int-index)