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

David Menendez dave at zednenem.com
Wed Jul 9 18:22:40 EDT 2008

On Wed, Jul 9, 2008 at 2:51 PM, Jason Dusek <jason.dusek at gmail.com> wrote:
> David Menendez <dave at zednenem.com> wrote:
>> I've often thought it would be for Haskell to steal Agda's
>> module syntax. It does pretty much everything you want (plus
>> some other stuff we maybe don't need) and the various things
>> it does fit together logically.
>  What does that look like? I've been looking for some kind of
>  documentation for ~20 minutes and I still can't find an
>  example of an import.

There's a description on their wiki at
There's a longer description in chapter 4 of Ulf Norell's thesis,
<http://www.cs.chalmers.se/~ulfn/papers/thesis.pdf>, which may be
slightly out of date.

Essentially, the import statement in Agda brings a module from another
file into scope as if it were a sub-module in the current file. It
also lets you rename the module, in case it conflicts with another
name. It does not bring any values or types into scope; they are
accessed by qualified names.

    import Some.Module
    import Some.Other.Module as SOM

A separate statement lets you bring names from any module into the
current scope. You can provide a list of names to include or exclude,
and a list of names to rename.

    open SOM using (x,y)
    open SOM renaming (x as alsoX, y as alsoY)
    open SOM hiding (x,y)

You can combine renaming with using or hiding, but you can't use using
or hiding together. Note that hidden names are still accessible as
qualified names. That is, if you open SOM hiding x, you can still say

There's also a short-hand form that lets you import a module and open
it on the same line.

Aside from the syntax differences, Agda's module system features
nested modules and parameterized modules, both of which could be
pretty handy in Haskell.

Nested modules allow libraries which have many modules with similar
names to use qualified names.

    open import Gtk using (module Button, module Window)

    f = ... Button.name ... Window.name ...

Parameterized modules work sort of like implicit arguments. I suspect
that having them in Haskell could eliminate most of the call for
things like top-level IORefs.

Dave Menendez <dave at zednenem.com>

More information about the Haskell-Cafe mailing list