[Haskell-cafe] Design your modules for qualified import

Jan-Willem Maessen jmaessen at alum.mit.edu
Fri Jun 6 08:47:02 EDT 2008

On Jun 6, 2008, at 8:12 AM, Wolfgang Jeltsch wrote:

> Am Donnerstag, 5. Juni 2008 17:19 schrieb Johan Tibell:
>> […]
>> 2. It's the default. You have to add "qualified" to all your imports
>> to make them qualified. In most language imports are qualified by
>> default. I think the latter would have been a better choice but we
>> have to live with the current design so bite the bullet and add those
>> qualified keywords to your imports.
> If you leave out “qualified”, you still get the qualified names  
> imported.  And
> if you use conflicting identifiers always qualified then there’s no  
> problem.
> For example, you can use
>    import Data.Set as Set
>    import Data.List as List
> and then just say Set.null or List.null.

There's one caveat: Always choose descriptive names, even if you are  
assuming that you will usually use a qualified import.  The following  
are wonderful names, even though they conflict with the prelude:

The following are terrible names:

What's a T?  What's a C?  There's no excuse to give something a lousy  
name just because the enclosing module is descriptively named.  I  
reject the naming conventions used by ML modules when writing Haskell  
code: Haskell modules are not ML modules.

-Jan-Willem Maessen

More information about the Haskell-Cafe mailing list