6.3.4. Explicit namespaces in import/export¶
-
ExplicitNamespaces
¶ Implied by: TypeOperators
,TypeFamilies
Since: 7.6.1 Enable use of explicit namespaces in module export lists.
In an import or export list, such as
module M( f, (++) ) where ...
import N( f, (++) )
...
the entities f
and (++)
are values. However, with type
operators (Type operators) it becomes possible to declare
(++)
as a type constructor. In that case, how would you export or
import it?
The ExplicitNamespaces
extension allows you to prefix the name of
a type constructor in an import or export list with “type
” to
disambiguate this case, thus:
module M( f, type (++) ) where ...
import N( f, type (++) )
...
module N( f, type (++) ) where
data family a ++ b = L a | R b
The extension ExplicitNamespaces
is implied by
TypeOperators
and (for some reason) by TypeFamilies
.
In addition, with PatternSynonyms
you can prefix the name of a
data constructor in an import or export list with the keyword
pattern
, to allow the import or export of a data constructor without
its parent type constructor (see Import and export of pattern synonyms).