
Hello all, (before I start I should say I'm relatively new (a few months) to haskell, so I'm not exactly savvy with the use of the compilers) I have a problem using the cabal with version 6.4.2 of ghc, the same thing occurs with two projects which I wish to compile, I'll use the simplest one since the problem seems to be the same in both cases. The program is a very simple printer thing for haskell the source of which you can download at: http://homepages.inf.ed.ac.uk/s9810217/software/haskell_print/haskellprint.t... http://homepages.inf.ed.ac.uk/s9810217/software/haskell_print/haskell_print.... (but you probably won't need to, in order to diagnose this problem) I wish to compile this with the sequence of commands: ./Setup.hs configure --user --prefix=/home/allan/install ./Setup.hs build this works perfectly on version 6.4 of ghc, however with version 6.4.2 I get the following error: haskellprint$ ./Setup.hs build Preprocessing executables for haskellprint-0.1... Building haskellprint-0.1... Chasing modules from: Main.hs Could not find module `Text.ParserCombinators.Parsec': use -v to see a list of the files searched for (imported from ./Parser.hs) haskellprint$ Now if I run haskellprint$ ./Setup.hs build --verbose then I can see the command line used to compile the program which is: /home/allan/install/bin/ghc -Idist/build -o dist/build/haskell_print/haskell_print --make -Wall -hide-all-packages -i -idist/build/autogen -i. -odir dist/build/haskell_print/haskell_print-tmp -hidir dist/build/haskell_print/haskell_print-tmp -package base-1.0 Main.hs If I copy and paste this into the command line and remove the argument [ -hide-all-packages ] then the program compiles fine. So basically my question is: what am I doing wrong? I assume my problem is in the .cabal file, so I include the contents here: name: haskellprint version: 0.1 license: GPL license-file: LICENSE author: Allan Clark maintainer: a.d.clark@ed.ac.uk build-depends: base executable: haskell_print main-is: Main.hs include-dirs: c-sources: other-modules: extra-libraries: extensions: ghc-options: -Wall -- ghc-options: -fwarn-incomplete-patterns -fwarn-missing-fields -- ghc-options: -prof -auto-all -Wall -fglasgow-exts -O -funbox-strict-fields -fasm -optl-Wl,-s thanks in advance for any help. allan

On Sun, 2006-07-30 at 15:01 +0100, allan wrote:
however with version 6.4.2 I get the following error:
haskellprint$ ./Setup.hs build Preprocessing executables for haskellprint-0.1... Building haskellprint-0.1... Chasing modules from: Main.hs Could not find module `Text.ParserCombinators.Parsec': use -v to see a list of the files searched for (imported from ./Parser.hs)
The Text.ParserCombinators.Parsec modules are in the parsec module.
build-depends: base
Add parsec here: build-depends: base, parsec The reason it works when you run it without -hide-all-packages is that by default for convenience all packages are 'exposed'. That is they can be used without explicitly having to specify them. However it was felt that for distributing software, which is one of the main purposes of Cabal, one should be fully explicit about the dependencies so that users compiling on other machines know exactly what packages needed and don't end up with mysterious import errors. Now it's true that Cabal could be a bit cleverer here and warn you before it even starts compiling that you have not specified all the right packages in the build-depends. At the moment however Cabal doesn't have a proper imports chaser so it can't do this. Duncan

The Text.ParserCombinators.Parsec modules are in the parsec module.
build-depends: base
Add parsec here:
build-depends: base, parsec
The reason it works when you run it without -hide-all-packages is that by default for convenience all packages are 'exposed'. That is they can be used without explicitly having to specify them. However it was felt that for distributing software, which is one of the main purposes of Cabal, one should be fully explicit about the dependencies so that users compiling on other machines know exactly what packages needed and don't end up with mysterious import errors.
Yip this sounds like a good policy to me too.
Now it's true that Cabal could be a bit cleverer here and warn you before it even starts compiling that you have not specified all the right packages in the build-depends. At the moment however Cabal doesn't have a proper imports chaser so it can't do this.
Duncan
Thanks very much for the response, however, adding "parsec" to the build-depends of the .cabal file now causes a slightly different error, and in fact this is the same error I get with my other project: haskellprint$ ./Setup.hs build Preprocessing executables for haskellprint-0.1... Building haskellprint-0.1... Chasing modules from: Main.hs Could not find module `Char': use -v to see a list of the files searched for (imported from ./Parser.hs) haskellprint$ so basically I was expecting 'Char' to be in the 'base' package, I guess this is wrong? thanks again. allan

Hi
so basically I was expecting 'Char' to be in the 'base' package, I guess this is wrong?
Yes, Char is in the haskell98 package, the new name for Char is Data.Char which exports a bit more. Either add haskell98 as a package, or replace Char with Data.Char (which is in base), I'd recommend the latter, but either should work. Thanks Neil

Yes, Char is in the haskell98 package, the new name for Char is Data.Char which exports a bit more. Either add haskell98 as a package, or replace Char with Data.Char (which is in base), I'd recommend the latter, but either should work.
Thanks
Neil
a ha, that works, thank you both very much, I can sleep easy now. allan
participants (3)
-
allan
-
Duncan Coutts
-
Neil Mitchell