My cabal package originally had this structure:
- lib
- Foo.App.*
- Foo.Lib.*
- exeuctables
- bar-exe
- baz-exe
- ...
I wanted to prevent the modules in Foo.App
from being built with the library, as they are only used by executables. I restructured it like this:
- lib
- Foo.Lib.*
- common app-deps
- Foo.App.*
- exeuctables
- bar-exe (import app-deps)
- baz-exe (import app-deps)
- ...
However, this seems to be causing the modules in Foo.App
to be built twice - once during the bar-exe build and once during baz-exe build. I’m inferring this from the significantly increased build time and multiple GHC processes that appear when using the new layout.
Additionally, there are many FromJSON
/ToJSON
instance derivations from aeson in Foo.App.*
. I believe this is causing instance resolution to occur for each executable build.
How can I prevent this duplication while maintaining the separation of concerns between library and executable-specific code?