Cleaning up hooks

Ian Lynagh igloo at earth.li
Tue May 1 11:41:39 EDT 2007


On Tue, Apr 24, 2007 at 09:45:54AM +0100, Simon Marlow wrote:
> I think the API for hooks is in need of an overhaul.

I agree.

> 4. tools that build on Cabal (e.g. cabal-rpm) don't work with hooks.
>    If your Setup.hs uses hooks to modify the PackageDescrption, then
>    cabal-rpm won't see the modifications.

That's something I think you just shouldn't be doing, and hopefully we
won't need to after this summer.

> Anyway, here's the basic idea.  A common thing to want to do in Setup.lhs 
> is to modify the PackageDescription, so we provide a way to do that:

Again, I don't think that'll be true after the configurations stuff is
implemented.

>  thenHook :: Hook a -> Hook a -> Hook a
>  thenHook hook1 hook2 args flags pd lbi = do
>    hook1 args flags pd lbi
>    hook2 args flags pd lbi
> 
> Then to add a post-hook to the build command you could do this:
> 
>  addPostBuild :: Hook BuildFlags -> Hooks -> Hooks
>  addPostBuild hook hooks
>    = hooks { buildHook = buildHook hooks `thenHook` hook }

I think most of the time we would want `thenHooks` (defined in terms of
thenHook), e.g. (with the current names) we'd have something like:

    defaultBuildHooks = simpleBuildHooks `thenHooks` configureBuildBooks

where configureBuildBooks might define a confHook (to run ./configure)
and a cleanHook (to remove config.log etc).


Thanks
Ian



More information about the cabal-devel mailing list