Hmmm, it does appear to aim at a very similar goal, but that branch only builds with old cabal versions, and even though I've made my code override the same functions, it still doesn't expose the dynamically-generated modules on normal import, only on "cabal repl". But I also noticed that "cabal repl" also exposes all the hidden modules, so maybe that isn't a good indication...anyways, I'm stumped for the moment on why modifying the exposed modules list at the confHook stage doesn't get propagated to the later stages. Like I said, the modules do get compiled, just not exposed.

On 11/28/2015 11:14 AM, Adam Bergmark wrote:
I believe this does the same thing as what you want:


On Sat, Nov 28, 2015 at 4:23 PM, Thomas Lippincott
< <>> wrote:


    I'm seeing what I think is some strange (or at least, non-intuitive)
    behavior in a custom package, and was wondering if someone could
    point me in the right direction.  Basically, I need the build
    process to generate some additional exposed modules, i.e. add them
    to the "exposed-modules" variable, and create the corresponding
    source files. It's easy to get the list of modules and produce the
    source files at any point in the build process (I know this is a
    questionable design, trying to do this as part of Cabal, but suffice
    it to say there are good arguments on both sides for our particular

    I'm *so* close to having it working perfectly: in fact, if I run
    "cabal repl", I get a shell with all the right modules compiled and
    exposed, so, it should work the same way if it's installed and
    imported in ghci, right?  Well, when I do that, the auto-generated
    modules are *not* exposed.  It's clearly generating the source files
    and compiling them, maybe "cabal install" isn't getting the updated
    module list or something?  Here's what I'm doing:

    I override "confHook" to call the original configure function, but
    then get the list of auto-generated modules and add them to the
    exposedModules field in the Library structure nested in the
    LocalBuildInfo structure before returning it.  The idea is that I've
    intercepted the list of exposed modules as early as possible, and so
    it's as though the Cabal file had the auto-generated modules listed
    from the start.  I generate the actual source files by overriding
    "preBuild".  Nothing else is modified from the default simpleUserHooks.

    This probably isn't the place for "how do I..." questions, so I'll
    frame it as: why would "cabal repl" work, and "cabal install" and
    ghci+import not work?  I apologize if this is an inappropriate place
    to ask, but there aren't exactly a ton of Cabal experts floating around!

    Thanks for any help,

    cabal-devel mailing list <>

cabal-devel mailing list

Reply via email to