[Haskell-cafe] Design your modules for qualified import

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Mon Jun 9 14:41:05 EDT 2008

On Mon, 2008-06-09 at 16:04 +0200, Ketil Malde wrote:

> I think designing modules for qualified-only use is a mistake.  I also
> think import lists get quite ugly, with multiple instances of
>       import qualified Data.Set as S
>       import Data.Set (Set)
> for multiple - sometimes even the majority - of modules.

As far as I can see that is the only downside, having to import more
than once to get the type name unqualified with the rest of the module

> Add to this that people will assign a variation of abbreviations for
> modules, we quickly lose consistency.

The obvious consistent thing to do is to use the last part of the module
name, at least for short names like Set and Map. For ByteString it is
more of a mouthful.

      import qualified Data.Set as Set
      import Data.Set (Set)

      Set.empty, Set.insert etc etc.

> And - is there a way to make GHCi use aliased qualification?  I find
> my self typing detailed taxonomies all the time there.

The ghci syntax currently is:
:m Data.Set
wouldn't it be much nicer as:
import Data.Set
then we could have the obvious:
import Data.Set as Set


More information about the Haskell-Cafe mailing list