[Haskell-cafe] Qualified import syntax badly designed (?)

allan a.d.clark at ed.ac.uk
Wed Jul 9 06:33:08 EDT 2008

Neil Mitchell wrote:
> Hi
>> Just to say that I also like this design. A minor point would be; do we
>>  really need the parentheses and commas? or could we not just use
>>  indentation (I think this about module imports in general).
[snip general agreement]
> However, I think the new syntax for modules, and the new type of
> declarations for modules, are separate issues.


>>  Also I wouldn't mind 'as' for the names which are imported which would
>>  be a bit of a work around for the debate as to whether I should design
>>  my modules for qualified import or not. Suppose I make a 'NewList'
>>  module and use the default names then someone could do:
>>  import Data.NewList
>>   unqualified map  as nlMap
>>               find as nlFind
>>               lookup as nlLookup
> I believe old versions of Haskell had this, and it was considered too
> confusing. Consider:
> import Prelude unqualified (+) as (-)
> Also people reading the code will find it easier to know N =
> Data.NewList (one mapping), than three mappings as you have.

Yes I generally agree there, I don't think 'as' for imported names is
particularly important and if it's been tried before and found to be
confusing well then that pretty much settles it for me.
If I were particularly for it then I'd point out that:
import Prelude unqualified (+) as (-)
would only be written by someone with limited common sense or someone
trying to break things (but I'm sure you could come up with a more
realistic example).
More importantly for me is the consistency you mentioned, for me it
seems inconsistent that you can remap a module name but not an imported
identifier. That said, your point about knowing one or three mappings is
somewhat compelling and I'm now somewhat less in favour of 'as' for
imported names.


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

More information about the Haskell-Cafe mailing list