[Haskell-cafe] Cabal question

Jurriaan Hage J.Hage at uu.nl
Mon Jul 21 06:33:29 UTC 2014

Hello Rogan,

Thanks for the info.
I was aware of this facility, and my mail was written in the hope that I could avoid it.

When you talk of the problem of dependencies below, I suppose (and hope) you do NOT mean 
that the package I want to compile can only depend on the listed packages,
just the Setup.hs code itself. Or am I naive here?


On 19Jul, 2014, at 17:49, Rogan Creswick <creswick at gmail.com> wrote:

> On Sat, Jul 19, 2014 at 4:33 AM, Jurriaan Hage <J.Hage at uu.nl> wrote:
> What I still need is a way to run some kind of postprocessing (like running
> a Makefile) after installation (as it happens this is for compiling the
> libraries that come with Helium).
> You can do this with a custom cabal build type, a non-trivial Setup.hs.  Cabal exposes a bunch of 'user hooks' that let you specify functions to be run at various stages of the compilation (such as pre-build, post-install, etc...).
> See the API here for the hooks available:
>   - http://www.haskell.org/ghc/docs/7.6.3/html/libraries/Cabal/Distribution-Simple-UserHooks.html
> I use prebuild hooks quite a lot to pre-process GF files (for the grammatical framework); one relatively simple example is shown in my gfI8N package: https://github.com/creswick/gfI8N
> Note that the cabal file uses `build-type: Custom` (which causes cabal to actually use the Setup.hs).
> The relevant part of the Setup.hs is:
> import Distribution.Simple
> import Distribution.Simple.Program.Types
> import Distribution.Simple.Setup
> import Distribution.Simple.UserHooks
> import Distribution.Simple.Utils ( rawSystemExit, warn, debug
>                                  , findProgramVersion, notice )
> import Distribution.Verbosity ( Verbosity )
> main = do
>   defaultMainWithHooks simpleUserHooks
>        { preBuild = \a b -> generatePGF a b >> preBuild simpleUserHooks a b
>        , preClean = \a b -> preClean simpleUserHooks a b
>        }
> That should be enough to get you going -- now some cautions, and a minor rant ;)
> Working with these hooks has lead me to /really/ want a way to express dependencies for Setup.hs files.  You *can not* use any hackage libraries in the definitions of these hooks and retain a portable build, because there is no way to indicate that the Setup.hs depends on such things. It used to be the case that you could assume that the dependencies of your library / executable would be visible, but with sandboxed builds that assumption is no longer valid. There's a cabal ticket for this feature here: https://github.com/haskell/cabal/issues/948
> You should be able to rely on these packages (which shipped with ghc -- the versions will depend on the ghc version installed):
>    Cabal-1.16.0
>    array-
>    base-
>    bin-package-db-
>    binary-
>    bytestring-
>    containers-
>    deepseq-
>    directory-
>    filepath-
>    ghc-7.6.3
>    ghc-prim-
>    haskell2010-
>    haskell98-
>    hoopl-
>    hpc-
>    integer-gmp-
>    old-locale-
>    old-time-
>    pretty-
>    process-
>    rts-1.0
>    template-haskell-
>    time-
> --Rogan
> Does anyone know here whether that is supported
> and how, without having to resort to build-types like Make that for I actually
> want to avoid?
> best,
> Jur
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list