cabal hooks interface

Isaac Jones ijones at
Fri Dec 10 11:40:35 EST 2004

"Simon Marlow" <simonmar at> writes:

> On 09 December 2004 23:56, ross at wrote:
>> On Wed, Dec 08, 2004 at 10:42:26PM -0800, Isaac Jones wrote:
>>> What about this interface for user-supplied command hooks.  [...]
>>> For each of the pre-functions, a Maybe PackageDescription is
>>> returned. If Nothing, then it gets the description from the file or
>>> the default description you passed in.  If (Just p), then it uses
>>> the description returned by the pre-functions.
>> I'm not sure what's going on here.  It seems only preConf needs to
>> return anything, and that shouldn't be the whole PackageDescription
>> (since you want part of that static), just the build information.

Each command needs access to the PackageDescription.  The reason the
hooks are like this is that we need to pass information between the
commands via the file system.

If the PreConf function were to return anything, it would be passed to
configure, and all configure could do with it is write it to the
configure file, which the future commands know how to read in, but
that doesn't have the build information like the module list.

So what the preConf step needs to do, is perhaps call autoconf on, and preBuild reads mySetup.description,
likewise for preInstall.

This is how we pass information from command to command.

>>> I don't particularly like the idea of: {{system "runhaskell"
>>> ["postinst.hs"]}} because it seems like a less elegant IO ExitCode.
>>> runhaskell doesn't exist, and it relies on more moving parts.
>> Sure it exists -- I read about it in the spec.
> Ross's solution lets you put the postinst code in the setup script
> itself, or optionally in an external script if you prefer.  This seems
> more flexible to me.

The commands need a way to pass information between one-another.  If
we use 'system' to run external commands, then the only way to do that
is to dump a file that cabal itself knows how to read back in, and
cabal has to know where it is.  If we rather use the preHooks, Angela
can do whatever she wants to get the information between phases, so
long as she returns a PackageDescription.

If we use 'system' calls, then Cabal must specify the names of the
scripts and the format and location of the files they output (or
preHooks with an interface similar to mine to read them back in).  If
Cabal use the preHooks, then all we need to specify is the type of the

The preHooks let the user do the obvious thing, which is to read and
write to a separate description file of their choosing, or to do
something as strange as they like to get the package description.

In any case, you can just say defaultUserFunctions{postInst=system
"./postinst.hs">> readPackageDescription "thePlaceIKnowItWillEndUp"}.



More information about the Libraries mailing list