On Fri, Jul 11, 2008 at 12:08:20AM +0100, Duncan Coutts wrote:
>
> On Tue, 2008-07-08 at 21:26 +0000, David Roundy wrote:
> > David Roundy <daveroundy@gmail.com> added the comment:
> >
> > On Wed, Jul 2, 2008 at 6:51 AM, Duncan <bugs@darcs.net> wrote:
> > >
> > > Duncan <duncan@haskell.org> added the comment:
> > >
> > > The key bit is:
> > >
> > > configure:5165: checking for module Control.Monad.Error
> > > configure:5186: ghc -threaded -package regex-compat -package HTTP -package
> > > QuickCheck -o conftest conftest.hs
> > >
> > > conftest.hs:1:0:
> > > Failed to load interface for `Control.Monad.Error':
> > > it was found in multiple packages: mtl-tf-0.1 mtl-1.1.0.0
> > > configure:5189: $? = 1
> > > configure: failed program was:
> > > import Control.Monad.Error
> > > main = seq (strMsg "foo" :: String) (putStr "Hello world.\n")
> > >
> > > -- this file generated by TRY-COMPILE-GHC
> > > end of failed program.
> > > configure:5222: ghc -threaded -package regex-compat -package HTTP -package
> > > QuickCheck -package mtl -o conftest conftest.hs
> > >
> > > conftest.hs:1:0:
> > > Failed to load interface for `Control.Monad.Error':
> > > it was found in multiple packages: mtl-tf-0.1 mtl-1.1.0.0
> > > configure:5225: $? = 1
> > > configure: failed program was:
> > > import Control.Monad.Error
> > > main = seq (strMsg "foo" :: String) (putStr "Hello world.\n")
> > >
> > > -- this file generated by TRY-COMPILE-GHC
> > > end of failed program.
> > > configure:5238: result: no; and neither in package mtl
> > > configure:5240: error: Cannot find Control.Monad.Error; try installing package mtl?
> > >
> > > So when ghc/ghci finds the module in multiple packages then it complains. The
> > > solution is to look in a specific package and not in all packages. This can be
> > > done by hiding all the packages you're not interested in with the
> > > -hide-all-packages ghc flag. eg:
> >
> > I'm confused. We did specify that we wanted to use the package mtl,
> > why do we also have to tell ghc not to use any packages at all? Is the
> > real problem that both packages start with mtl? To me, that sounds
> > more reasonable than adding --hide-all-packages, but I'm not really
> > clear as to what the effect of --hide-all-packages is. ghc doesn't
> > normally look in any packages that aren't specified on the
> > command-line (although ghci does).
>
> You're right it's odd. I would have expected it to only look in the
> packages given by -package flags (+ hard-wired packages like base) when
> not in --make or ghci mode. However that does not seem to be the current
> ghc behaviour. It seems to look in all packages for modules for
> compiling but then only the given ones for linking (nice inconsistency).
>
> So to really make it only look in the given packages it looks like
> -hide-all-packages is necessary. Of course that also means having to
> explicitly add -package base since -hide-all-packages really means what
> it says (it otherwise cannot find the Prelude).
So (summarizing to make sure I understand you) the conclusion is that
to restore sane behavior, we can just add "-hide-all-packages -package
base" to all our invocations of ghc? From what you describe, that's
what I always believed it did. Might this be a change in behavior? It
seems downright ridiculous! (A quick test confirms what you describe,
that when compiling ghc 6.6 looks at modules that aren't explicitly
specified.)
--
David Roundy
Department of Physics
Oregon State University |