Patch to expose reportProgram in Distribution.Simple.Configure

Dominic Steinitz dominic at
Sat Jun 6 05:32:58 EDT 2009

Duncan Coutts wrote:
> Sorry, I've been slow in replying.

No problem. I appreciate your response.I realise I am also slow in
replying but I only seem to have time at weekends these days.

> I tend to be a bit reluctant to expose more internal functions to Setup
> scripts. It means there's more stuff we can't change without breaking
> packages.
> In this case I'm not convinced you need it, running your Setup.hs I get
> duplicate reports for the programs in question because configure already
> reports them. The extra warnings are fine of course.

Obviously, I don't want duplicate reports. But I would like finer
control of messages. I think I have a valid requirement. What do you
suggest? Cutting and pasting code seems worse than exposing a function.
Or maybe something else could be beefed up to allow the user (i.e. me)
finer control of warning messages?

I did think the interface was slightly clunky but it's probably me
mis-using it. I seemed to have to specify things twice.

Once here:

> perHooks =
>    simpleUserHooks {
>          hookedPrograms = [
>               simpleProgram "pdflatex"
>             , simpleProgram "asn1c"
>           ]
>       , postConf = perPostConf
>    }

And then because I wanted finer control over the warning messages I
specified things again. I suspect I could get rid of hookedPrograms (and
possibly simpleUserHooks). But then I need a function to display the
results and reportProgram almost does the job (it's just not exposed).

> perPostConf :: Args -> ConfigFlags -> PackageDescription  -> LocalBuildInfo -> IO ()
> perPostConf a cfs pd lbi =
>    do let v       = fromFlagOrDefault normal (configVerbosity cfs)
>           pdfSP   = simpleProgram "pdflatex"
>           mPdf    = lookupProgram pdfSP (withPrograms lbi)
>           asn1cSP = simpleProgram "asn1c"
>           mAsn1c  = lookupProgram  asn1cSP (withPrograms lbi)
>           cSP     = simpleProgram cCompilerName
>           mC      = lookupProgram cSP (withPrograms lbi)
>       case mPdf of
>          Nothing -> 
>             warn v "Full documentation cannot be built without pdflatex" >> return ()
>          Just _ -> do
>             reportProgram v pdfSP mPdf
>             return ()
>       case mAsn1c of
>          Nothing -> 
>             warn v "Full inter-operability testing cannot be performed without asn1c" >> return ()

Possibly a bit more explanation in the documentation
would help people like me. Something like "If you want to check for
programs then use hookedPrograms and you will get the cabal standard
messages. If you want finer control then use lookupProgram and
reportProgram e.g. ..."


More information about the cabal-devel mailing list