0
votes

I recently installed the Haskell Platform for Windows for a programming class I'm taking. It includes GHCi as a compiler and Cabal as a packaging system. I've been trying to install the Craft3e package with Cabal, as this is the exercise package that my textbook uses, but to no avail. To install Craft3e, I just enter cabal unpack Craft3e in the command prompt, which creates the directory "\Craft3e-0.1.0.8". After entering the directory, I type cabal install --disable-documentation, which gives me the following message:

Resolving dependencies...
In order, the following would be installed: 
time-1.2.0.5 (new version)
random-1.0.1.1 (reinstall) changes: time-1.4 -> 1.2.0.5
QuickCheck-2.5.1.1 (reinstall)
Craft3e-0.1.0.8 (new package)
cabal: The following packages are likely to be broken b
haskell-platform-2012.4.0.0
Use --force-reinstalls if you want to install anyway.

After using cabal install --disable-documentation --force-reinstalls, it install as expected. I load a module to test it out: ghci PicturesSVG. This loads successfully. However, once I quit the GHCi compiler and go back into it, I can no longer load the modules from the Craft3e packages; instead, I get the message:

GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.

<command line>:
    Could not find module `PicturesSVG'
    it is a hidden module in the package `Craft3e-0.1.0.8'
    Use -v to see a list of the files searched for.
 Failed, modules loaded: none.

What happened? The package still shows up when I enter ghc-pkg list. I've tried entering ghc-pkg expose Craft3e-0.1.0.8, but the prompt tells me:

WARNING: cache is out of date: C:/Program Files (x86)/Haskell Platform/2012.4.0.
0\lib\package.conf.d\package.cache
  use 'ghc-pkg recache' to fix.

I've done the recache, and re-entered the "expose" command, but still no results.

Any solutions would be really appreciated!

3

3 Answers

3
votes
cabal: The following packages are likely to be broken b
haskell-platform-2012.4.0.0

That is a very bad sign. You should only use --force-reinstalls if you know very well what you're doing, which, as a new learner, you more or less by definition don't. cabal should probably warn more sternly.

The root of the problems is that the package's dependencies are specified too strict for it to work with ghc-7.4 or later by default, as they come with a time package version that is larger than allowed by craft3e's .cabal file. The proper fix for that problem would have been to relax the dependency bound on time (should have been done by the author, but before a fixed version is on hackage, the user should edit the .cabal file to allow time-1.4.* if (s)he has a ghc >= 7.4, so the package can be built without reinstalling anything and thereby probably breaking installed packages).

The reinstall of time, random and QuickCheck likely broke a number of packages, run ghc-pkg check from the command line to get an assessment of the damage. Maybe just ghc-pkg unregistering time-1.2.0.5 and reinstalling random and QuickCheck would fix it, maybe you need to reinstall more, perhaps the entire platform.

After the broken packages have been fixed one way or another, go to the Craft3e-0.1.0.8 directory, edit the Craft3e.cabal file, changing the line

time >= 1.1 && < 1.3,

in the build-depends field to

time >= 1.1 && < 1.5,

and run cabal install --disable-documentation there.


Could not find module `PicturesSVG'
it is a hidden module in the package `Craft3e-0.1.0.8'

Right. The package doesn't expose any modules, so all modules it comes with are hidden (not sure whether that's really intended). You can load them only from the directory they are in, since ghci prefers loading source files from the current directory (tree) to package modules. If you invoke ghci from that directory, it should load the file. (Or you can also specify the path to the directory when invoking ghci from another directory, ghci -ipath/to/Craft3e-0.1.0.8 PicturesSVG.)

2
votes

The Craft3e packege doesn't actually expose any modules. The cabal file seems to be there mostly for distribution- and dependency purposes, not to give you a proper library interface, so to load any of the modules you always need to open explicitly the file where it's included.

1
votes

I have updated the Craft3e package to take into account the new version of Time. Apologies for any problems caused.