[jhc] new extension in jhc: explicit namespaces in import/export lists

John Meacham john at repetae.net
Mon Feb 13 09:24:34 CET 2012


On Sun, Feb 12, 2012 at 11:26 PM, Roman Cheplyaka <roma at ro-che.info> wrote:
> * John Meacham <john at repetae.net> [2012-02-12 19:26:24-0800]
>> In haskell 98 [...]
>
> Not sure what you mean here. You aren't going to modify an existing
> standard, are you? :)
>> [...] a name such as 'Foo' in an export list will indicate that all of
>> a class named Foo, a type named 'Foo' and a data constructor named
>> 'Foo' shoud be exported.
>
> This bit doesn't sound right... I think this behaviour would be
> something that people will more often fight against (by using
> namespaces) than appreciate. (Esp. that Foo exports both the type and
> the data constructor.)

Yeah, I worded it incorrectly, actually it is more that I read my own
code incorrectly :)
The data constructor isn't matched. as stands
my extension behaves identically to h2010 rules when no namespace
specifiers are used.  When a namespace specifier
is used, the declaration is restricted to just the names that match
that namespace.
So it is transparent when not used.

> How about this:
>
> Foo in the export list may refer to a class, a type or a kind (but not a
> data constructor). It is an error if multiple entities with the name
> Foo are in scope.

Allowing multiple things of the same name was part of the goal, in
that you can use the explicit namespaces to restrict it if it is what you
intend.. But I suppose that could be considered an independent change.

In any case, part of the reason for implementing this in jhc was to
experiment with variants like this too see what works.

Actually, perhaps a better rule would be "it is an error if multiple entities
within the same namespace are matched"

hmm.. not sure on that one yet...

> I see your point regarding 'hiding' inconsistency, but I'd prefer having
> 'hiding' fixed (in a similar way).

Yeah, it is just annoying that there is this one exception.

    John



More information about the Haskell-prime mailing list