Instance declarations and class exports
Tue, 11 Dec 2001 10:36:27 +0000
> I therefore want to propose:
> 1. "subordinate" names in export lists are always unqualified
> Thus, we can have M.Ix( index ), but not M.Ix( T.index ).
I don't see a compelling reason to outlaw the latter. We can permit
the subordinate name to be unqualified, but why should we enforce it?
Ditto for method names in instance decls.
> I'd like to find a better wording for (2):
> 2. A subordinate name in an export list is legal if the entity (class
> operation or data constructor) is in scope in the module, regardless
> of whether it is in scope under a qualified or unqualified name.
> (In the example, T.index.)
A method name, constructor, or field name is permitted to be used
unqualified in a subordinate position of an export list, iff the
entity it refers to is in scope in the module, regardless of whether
the name must be used qualified elsewhere in the module.
There is a distinction between a subordinate name (e.g. the index
method of Ix), and its use in a subordinate position (e.g. in
Ix(index)). In the example, it would be perfectly legal to say
module Foo( T.index ) where
import qualified Ix as M( Ix )
import qualified Ix as T( index )
index v = ... -- A local declaration
where the method name (but not its class) is re-exported.