[Haskell] Module system question

Iavor Diatchki iavor.diatchki at gmail.com
Tue Oct 16 07:14:54 EDT 2007


Hello,

On 10/16/07, Simon Peyton-Jones <simonpj at microsoft.com> wrote:
> The H98 report is pretty clear about there being a single name space for type constructors and classes.  Yes, in certain circumstances it's unambiguous.  In Hugs, can you write
>         module M where
>           class C a
>           data C = MkC
>           f :: C a =>  C -> C
> which is also unambiguous.

My version of Hugs (20050308) rejects this because it does not allow
the definition of a class and a datatype with the same name in the
same module.  If the class and datatype are imported from different
modules (as in the example I gave), then a type signature in Hugs
gives a rather strange error which to me looks like a bug :-)

ERROR "C.hs":1 - Ambiguous class occurrence "X"
*** Could refer to: B.X case.case

> I'm inclined to stick to the H98 story.

Seems reasonable---the situations where the extra cleverness is useful
are probably not that many and, in any case, one can always work
around by using a qualified name.  I recently noticed that the
alternative rule would be quite easy to implement in a compiler that I
sometimes play around with, and was wondering if that was what Haskell
implementations did anyways.

-- 
Iavor


More information about the Haskell mailing list