[Haskell] Module system question

Iavor Diatchki iavor.diatchki at gmail.com
Mon Oct 15 15:34:37 EDT 2007


I have a question concerning Haskell's module system.
Consider the following example which defines three modules A,B, and C:

> module A where { data X = X }
> module B where { class X a }
> module C where { import A; import B; data Y = Y X }

The question is: "Is there an ambiguity error in module C?".  It seems
that the answer depends on how we interpret "ambiguous".  In the
context of module C, the name X may refer to either the class defined
in module B, or the datatype defined in module A.  Therefore, we could
consider X to be ambiguous, and indeed, this is what happens in GHC
6.6.  On the other hand, the name X is used in a context where we are
expecting a type constructor and not a class name, and therefore the
name X could be unambiguously taken to refer to the datatype X, which
is what seems to happen in Hugs.

I like the Hugs behavior because it accepts more programs.  OTOH,
GHC's behavior may be a bit simpler to explain and implement(?).   Any


More information about the Haskell mailing list