base 3 + base 4 compatibility?
marlowsd at gmail.com
Mon Oct 6 10:49:00 EDT 2008
Claus Reinke wrote:
>>> -- pretend we're loading a package that depends on base 3 into a
>>> -- session that otherwise depends on base 4
>>> $ ./ghc-6.11.20081004/bin/ghcii.sh -package base-126.96.36.199
>>> Prelude> :m +Data.Generics.Basics
>>> Could not find module `Data.Generics.Basics':
>>> it was found in multiple packages: base-188.8.131.52 syb
>>> Even if there was syntax to add one of the two modules (temporarily
>>> hiding one of the packages resets the session, <package>:<name> isn't
>>> accepted), all of ghci would then have to disambiguate (in output and
>>> input) between the imported items and others of the same name, where
>>> a qualified name is no longer sufficient, eg
>> GHC is behaving correctly here, isn't it? If you want to use base-3
>> with GHCi or --make you probably ought to use -hide-all-packages and
>> specify exactly which packages you want in scope.
>> I'm not sure exactly what it is you want to happen instead. Could you
> I'll try - here is the scenario I had in mind:
> - package A depends on base-3
> - package B depends on base-4+syb
> - I want to use ghci to work on package C's code, where C depends on A+B
This should all work fine. If C depends on base-3, then you'll need to say
'ghci -hide-all-packages -package base-184.108.40.206 ... C.hs'.
Cabal really should invoke GHCi for you, because here we're asking the user
to do some of the work that Cabal already knows how to do, that is, figure
out what -package flags to give to GHC for their package. I suppose you
can always say 'cabal build -v', cut-and-paste the ghc command line and
replace 'ghc' by 'ghci'.
> Now, it seems I cannot refer to Data.Generics.Basics in a ghci session
> for C, even if that is what A is refering to, because both base-3 (via A)
> and syb (via B) are loaded, so the name is ambiguous (even if it ultimately
> refers to the same things).
Yes, and that's the right thing. By invoking GHCi without
-hide-all-packages, you're taking the current session from the packages
that are "exposed", which probably corresponds to the most recent version
of everything installed (but it doesn't have to). Exposed packages are
just a hack so you don't have to give -package flags to GHCi in the common
> That means I cannot use -hide-package&co, or so I thought. The best I
> can hope for is that there is a unique common ancestor module, and that
> I happen to know that I should look there, not in the modules that
> re-export this ancestor in different packages. For instance, of the
> following three, I
> can only name the first in that ghci session:
I think you're making everything sound more complicated than it really is!
There's nothing special going on here.
> Interestingly, when I try it out, it seems that I can hide base-220.127.116.11,
> while working with a package that depends on it (such as QuickCheck). In
> fact, if I try ':m +Data.Generics.Basics' in a 'ghci -package QuickCheck'
> session, the hiding happens implicitly:
> $ /cygdrive/c/ghc/ghc-6.11.20080925/bin/ghcii.sh -package QuickCheck
> GHCi, version 6.11.20080925: http://www.haskell.org/ghc/ :? for help
> Loading package ghc-prim ... linking ... done.
> Loading package integer ... linking ... done.
> Loading package base ... linking ... done.
> Loading package syb ... linking ... done.
> Loading package base-18.104.22.168 ... linking ... done.
> Loading package old-locale-22.214.171.124 ... linking ... done.
> Loading package old-time-126.96.36.199 ... linking ... done.
> Loading package random-188.8.131.52 ... linking ... done.
> Loading package QuickCheck-184.108.40.206 ... linking ... done.
> Loading package ghc-paths-0.1.0.5 ... linking ... done.
>> Prelude> :m +Data.Generics.Basics
>> Prelude Data.Generics.Basics> :set -v
>> hiding package base-220.127.116.11 to avoid conflict with later version
GHC notices when there are multiple packages of the same name exposed, and
hides one of them. It has done this for a long time (probably back to 6.6,
> So it seems that you've already thought of this, and the strategy is to
> the intermediate package base-18.104.22.168 and to work directly in base-22.214.171.124
> and syb. I was just confused because the behaviour is rather different
> in a 'ghci -package base-126.96.36.199' session (repeated at the top of this
> Is that difference intended?
Nope, there's nothing different going on. When you ask for base-188.8.131.52,
GHC hides base-4, and vice-versa.
More information about the Cvs-ghc