Personal tools

Upgrading packages/Updating to GHC 6.8

From HaskellWiki

< Upgrading packages
Revision as of 03:25, 9 October 2008 by DonStewart (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A list of things that need updating when porting packages to newer library/cabal versions.

If you maintain a Haskell package this is for you.


1 Updating to GHC 6.8 and Cabal 1.2

So now that GHC 6.8.x is out you'll want to test your package with it. We'd especially like maintainers of packages that are distributed on to test their packages and update them as necessary. However everyone would appreciate it if your packages will still work with GHC 6.6.x, so read below for details on how to do that.

1.1 base package split up

You'll most likely find that your package fails to build with GHC 6.8.x with an error message like this:

  Could not find module `Data.Map': it is a member of package
  containers-, which is hidden.
This is the first symptom of the change in the base library in GHC 6.8.x. Several parts of the old base library got split out into separate packages. For example
is now in the
package (see below for the complete list of #New core packages). Unfortunately this means most packages need updating.

1.2 Cabal configuration support

Of course you'd also like to make your packages continue to work with

GHC 6.6.x (and perhaps older). If you go and just add
to your package's
then it will no longer work with GHC 6.6.x or older. So the solution at the moment is to use Cabal configurations like so:
flag splitBase
  description: Choose the new smaller, split-up base package.
  if flag(splitBase)
    build-depends: base >= 3, containers
    build-depends: base < 3

Since this uses a new Cabal feature you'll have to make your packages require Cabal 1.2 or later:

cabal-version: >=1.2

This is ok since Cabal 1.2.x comes with GHC 6.8.x and can also be installed from hackage for older GHC versions.

For a bigger example see Cabal's own .cabal file

The new Cabal syntax is explained in the Cabal user guide

1.3 Cabal API changes

Many packages that use non-default
files need to be updated as they use Cabal APIs that have changed. In many cases new features in Cabal 1.2 allow these packages to go back to using the default

A more detailed survey of the packages from the hackage collection is here:

If your package does use the default
file then you can indicate this by adding the following line to your
build-type: Simple

This allows tools like cabal-install to avoid compiling the Setup.hs file at all. The other build types are explained in the Cabal user guide.

1.4 New core packages

The base package was split up, and new dependencies are now required;

  • array: Data.Array and below
  • bytestring: Data.ByteString and below
  • packedstring: Data.PackedString (deprecated)
  • containers: Data.{Graph,IntMap,IntSet,Map,Sequence,Set,Tree}
  • random: System.Random
  • pretty: Text.PrettyPrint and below
  • process: System.Cmd, System.Process and below
  • directory: System.Directory
  • old-time: System.Time
  • old-locale: System.Locale

(dependency graph of the core packages)

These core packages are included with GHC 6.8.x. If your package imports any of these modules, you need only add the corresponding package names to the
line in your .cabal file.

For example, the GHC error message

    Could not find module `System.Directory':
      it is a member of package directory-, which is hidden
indicates that
should be added to the

1.5 Data.ByteString api changes

Data.ByteString.packCStringLen is no longer a pure function; its signature has changed from

packCStringLen :: Foreign.C.String.CStringLen -> ByteString


packCStringLen :: Foreign.C.String.CStringLen -> IO ByteString
module Data.ByteString.Base
has been split into two. The "unsafe" functions moved to
and the others moved into
. The stable API going forward is all the modules exposed by the
package except for the
modules and the
module. The lazy
representation type has changed. Instead of a newtyped list:
newtype ByteString = LPS [Strict.ByteString]

it is now:

data ByteString = Empty | Chunk !Strict.ByteString ByteString
The crucial difference is that in the latter representation we can unpack the strict
into the
constructor which reduces the number of indirections to get at the string data from two to one.

1.6 Other core library api changes

They are listed in detail in the GHC 6.8 release notes