Discussion:
[Hugs-users] Scoping inconsistency in ghci
Ahn, Ki Yung
2009-11-24 03:37:14 UTC
Permalink
Running ghci without any option or scripts to load, I've experienced
some inconsistencies prelude List.\\ and List.(\\) . The former is in
scope, but the latter is not. This seem strange. My expectation is
that neither of them should be in scope unless we load the List module
with with the :m command.

I'm using Debian distribution of GHC 6.10.4, and here is an example run
of ghci to show this issue.

***@kyagrd:~/tmp$ ghci
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> [1,2,3,4] List.\\ [1,3]
[2,4]
Prelude> List.(\\) [1,2,3,4] [1,3]

<interactive>:1:0: Not in scope: data constructor `List'

<interactive>:1:5: Not in scope: `\\'
Prelude> :q
Leaving GHCi.
***@kyagrd:~/tmp$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.10.4
***@kyagrd:~/tmp$ uname -a
Linux kyagrd 2.6.30-2-686 #1 SMP Sat Sep 26 01:16:22 UTC 2009 i686 GNU/Linux
Ahn, Ki Yung
2009-11-24 03:45:08 UTC
Permalink
Sorry this was my complete confustion (List.\\) is not same as List.(\\).
Post by Ahn, Ki Yung
Running ghci without any option or scripts to load, I've experienced
some inconsistencies prelude List.\\ and List.(\\) . The former is in
scope, but the latter is not. This seem strange. My expectation is
that neither of them should be in scope unless we load the List module
with with the :m command.
I'm using Debian distribution of GHC 6.10.4, and here is an example run
of ghci to show this issue.
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> [1,2,3,4] List.\\ [1,3]
[2,4]
Prelude> List.(\\) [1,2,3,4] [1,3]
<interactive>:1:0: Not in scope: data constructor `List'
<interactive>:1:5: Not in scope: `\\'
Prelude> :q
Leaving GHCi.
The Glorious Glasgow Haskell Compilation System, version 6.10.4
Linux kyagrd 2.6.30-2-686 #1 SMP Sat Sep 26 01:16:22 UTC 2009 i686 GNU/Linux
Malcolm Wallace
2009-11-24 03:47:05 UTC
Permalink
List.\\ and List.(\\) . The former is in scope, but the latter is
not.
The first is a qualified operator, the second is not. The correct
syntax to make a qualified operator prefix is (List.\\). There has
been some discussion of changing it in Haskell Prime to match your
intuition for how it should look, but the change was rejected for
H'2010. Maybe it will be adopted in H'2011 or H'2012.
My expectation is that neither of them should be in scope unless we
load the List module with with the :m command.
Yes, ghci is decidedly strange in this respect. Any name from any
exposed package is available in qualified form at the command prompt,
without having to load the module containing it. Indeed,
frustratingly, ghci will often complain if you *do* try to load the
module:

Prelude> :l List
<no location info>: module `List' is a package module
Failed, modules loaded: none.

Regards,
Malcolm

Loading...