Re: Hat bug report: Ambiguous occurrence `List'

Fergus Henderson <[email protected]> Tue, 29 Jun 2004 18:33:09 -0700
Newsgroups gmane.comp.lang.haskell.hat
Message-ID <[email protected]>
On 29-Jun-2004, Malcolm Wallace <[email protected]> wrote:
> Fergus Henderson <[email protected]> writes:
> 
> > This one can be reproduced with a simple one-liner, "(>>) = 42":
> > 
> > 	bash$ cat Foo.hs
> > 	(>>) = 42
> 
> Hmm, but isn't (>>) indeed defined in the Prelude?

Yes.

> So what is the expectation here?

This example should be allowed.  hat-trans should generate a type-correct
translated Haskell program from it.

> Is it something to do with lazy reporting of name clashes?

Yes.

The name ">>" is defined in the Prelude, but this occurrence of ">>"
in Foo.hs is a definition, so it unambiguously refers to Main.>>,
not Prelude.>>.

The Haskell 98 report gives a similar example in section 5.5.2 "Name clashes",
using "sin" rather than ">>":

 | For example, the following module is legal:
 | 
 |   module F where
 | 
 |     sin :: Float -> Float
 |     sin x = (x::Float)
 | 
 |     f x = Prelude.sin (F.sin x)
 | 
 | The local declaration for sin is legal, even though the Prelude function sin is implicitly in scope.
 | The references to Prelude.sin and F.sin must both be qualified to make
 | it unambiguous which sin is meant. However, the unqualified name sin in
 | the type signature in the first line of F unambiguously refers to the
 | local declaration for sin.

-- 
Fergus J. Henderson                 |  "I have always known that the pursuit
Galois Connections, Inc.            |  of excellence is a lethal habit"
Phone: +1 503 626 6616              |     -- the last words of T. S. Garp.