GHC 5.02, import Prelude hiding ...
Fri, 12 Oct 2001 08:59:42 -0700
Thomas Hallgren says:
| The following program was accepted by previous versions of=20
| GHC, but is not in GHC 5.02
| module HidingBug where
| import Prelude hiding (lookup)
| lookup env x =3D Prelude.lookup x env
| Instead, you get the error message
| HidingBug.hs:4: Variable not in scope: `Prelude.lookup'
| This behaviour does not seem to agree with the=20
| Haskell 98 Report, which in section 5.6.1 says
| The Prelude module is imported automatically into all modules as
| by the statement `import Prelude', if and only if it is not
| with an explicit import declaration. This provision for explicit
| import allows values defined in the Prelude to be hidden from the
| unqualified name space. The Prelude module is always available as
| qualified import: an implicit `import qualified Prelude ' is part
| every module and names prefixed by `Prelude.' can always be used
| refer to entities in the Prelude.
An(other) excellent point. This didn't happen on purpose, but it
did happen for a reason.
In the current Report draft, the idea is that a hiding clause hides
both qualified and unqualified names
import Foo hiding( f )
hides Foo.f as well as unqualified f.
I think we all agreed that is a good change. But we (ahem, I) forgot
to propagate that change to the sections about the Prelude. It's
really odd to say
import Prelude hiding( map )
does *not* hide Prelule.map, after all. In GHC we didn't implement
this inconsistency, hence the original message.
I therefore PROPOSE to replace the current text with:=20
The Prelude module is imported automatically into all modules as if
by the statement `import Prelude', if and only if it is not imported
with an explicit import declaration. This provision for explicit
import allows values defined in the Prelude to be selectively
just like any other module.
The fact that this makes the Report behave like GHC is purely
Seriously, comments anyone?