
Recently, I had to add a MIN_VERSION macro to my code because of the old-time / time change in directory, but couldn't test the library in ghci because the macro was not defined.
I discovered that configuring ghci with
:set -optP-include -optPdist/build/autogen/cabal_macros.h
tells ghci about the macro, but I find this even more cumbersome than dist/build/<executable>/<executable>.
So, if I'm not missing something, it may also be comfortable to add a
cabal ghci
command which tells ghci about cabal's configuration.
You can put the required options in a .ghci file in you project root. I use [3] as a starting point for new projects, [2] and [3] are real world examples. `cabal ghci` could still be useful, but I think a general solution is not trivial. It would probably need to accept qualified targets, e.g. `ghci test:properties` to start ghci in a way suitable for a test-suite with the name "properties". Moreover, it would be awesome if it would regenerate generated source files on :reload. I'm not sure if this is feasible without changes to GHCi, but a custom macro, e.g. :cabal-reload could still work. Cheers, Simon [1] http://hpaste.org/77144 [2] https://github.com/ghc/haddock/blob/ghc-7.6/.ghci [3] https://github.com/sol/doctest-haskell/blob/master/.ghci