Personal tools

Cabal/FAQ

From HaskellWiki

< Cabal(Difference between revisions)
Jump to: navigation, search
m (add to FAQ category)
(add a question from the wikibook)
Line 14: Line 14:
   
 
Developers of packages who want to know how to update their package properly so that it will continue to work with old and new compilers should see [[Upgrading_packages]].
 
Developers of packages who want to know how to update their package properly so that it will continue to work with old and new compilers should see [[Upgrading_packages]].
  +
  +
== How do I handle extensions? ==
  +
If your code uses some of the advanced Haskell extensions, you have a number of options.
  +
# If you're distributing via Cabal, you can simply add <code>ghc-options: -fglasgow-exts</code> to your .cabal file.
  +
# You can use the OPTIONS_GHC pragma to supply the -fglasgow-exts on a per-file basis (as opposed to in the cabal file which would apply to every file), like thus: <haskell>{-# OPTIONS_GHC -fglasgow-exts #-}</haskell>.
  +
# The best way to do it, if you know your users are on GHC 6.8.x are the new LANGUAGE pragmas. ie, each extension has a name, and you only list those which you are using (you can find the list in [http://haskell.org/ghc/docs/latest/html/libraries/Cabal/Distribution-Extension.html Distribution.Extension]). So you can enable only those extensions you are using. Like before, you enable them in the cabal file, mention them like <code>extensions: CPP, ForeignFunctionInterface<code>.
  +
#Of course, even better is specifying them in only the file using them. A pragma might look like <haskell>{-# LANGUAGE CPP, ForeignFunctionInterface #-}</haskell>. (You'll probably still want to use the extensions field just to make clear at the top level what extensions the project uses.)

Revision as of 02:37, 5 April 2008

1 What is this hidden package?

You build a package and get a message like:

  Could not find module `Data.Map': it is a member of package
  containers-0.1.0.0, which is hidden.

This is because the package has not been updated for ghc-6.8 which has split the base package into lots of smaller packages. The package needs to be updated to say that it depends on these new split base packages, like containers, process and several others.

If you just want to get the package to build, add the missing package names to the build-depends: line in the .cabal file. For example given the above error message we would add the 'containers' package to the build-depends.

Developers of packages who want to know how to update their package properly so that it will continue to work with old and new compilers should see Upgrading_packages.

2 How do I handle extensions?

If your code uses some of the advanced Haskell extensions, you have a number of options.

  1. If you're distributing via Cabal, you can simply add ghc-options: -fglasgow-exts to your .cabal file.
  2. You can use the OPTIONS_GHC pragma to supply the -fglasgow-exts on a per-file basis (as opposed to in the cabal file which would apply to every file), like thus:
    {-# OPTIONS_GHC -fglasgow-exts #-}
    .
  3. The best way to do it, if you know your users are on GHC 6.8.x are the new LANGUAGE pragmas. ie, each extension has a name, and you only list those which you are using (you can find the list in Distribution.Extension). So you can enable only those extensions you are using. Like before, you enable them in the cabal file, mention them like extensions: CPP, ForeignFunctionInterface<code>.
  4. Of course, even better is specifying them in only the file using them. A pragma might look like
    {-# LANGUAGE CPP, ForeignFunctionInterface #-}
    . (You'll probably still want to use the extensions field just to make clear at the top level what extensions the project uses.)