This page gives a specification for how users should expect export lists to behave.
Specifically, we concentrate on the very complex case of type constructors exported with data constructors.
Syntax
We are concerned with exports of the form.
T(a_1, a_2, ..., a_n)
where a_1
to a_n
are a mixture of
- Data Constructors
- Record Selectors
- Class methods
- Type Constructors (in the case of associated types)
- Pattern Synonyms
- Pattern Synonym Record Selectors
- Wildcards
We then define two cases for each category.
- When it is valid to include in the export list.
- Which names are exported as a result of the inclusion.
We say that a_1
can be *exported with* T
in the case that the export is 1-valid.
Definition:
Semantics
-
A data constructor
D
can be exported withT
just whenT
is the parent ofD
. -
A record selector
f
can be exported withT
just whenT
is the parent ofD
. -
A type class method
foo
can be exported withT
just whenT
is a type class which definesfoo
. -
A type constructor
S
can be exported withT
just whenS
is an associated type defined in the type classT
. -
A pattern synonym
P
can be exported withT
in the case that either -
The head of the type of the scrutinee is a definite type constructor (not a type variable)
S
andT = S
. -
The head of the type of the scrutinee is a type variable
-
A pattern synonym selector
p
belonging to a pattern synonymP
can be exported withT
in the case thatP
can be exported withT
. -
A wildcard can always appear in the export list.
1-5. The thing itself is exported from the module.
- All children of
T
are exported from the module.