How to avoid recompilation in this cache file?

I am working on this Haskell project and I have a file for it. Now my project is structured as a library that implements a simple interpreter. I also have a very short main file that needs to be created in an executable to call the library. I want to do this:

1) compile the library and expose some of the modules

2) compile the executable file

I have a cabal file that works and seems to be doing this. The problem is that when compiling the executable file, it recompiles all the modules that were already compiled in step (1). I don’t quite understand why he does it - is there a way to stop him without creating two separate bondage files?

I really don’t want to create two separate cabal files, because the cabal doesn’t seem to like having both cabal files in the same directory, and I really don’t want to set up a separate project directory for the second step, since it basically comes down to compiling a single file.

cabal-version: >= 1.6 build-type: Simple name: HaSC version: 0.2.3 license: OtherLicense category: Language author: Chris B maintainer: Chris B copyright: Chris B 2010 - 2011 synopsis: (HA)skell (S)ound (C)hange applier (HaSC) library description: HaSC implements a little language for applying sound changes to words homepage: http://www.chrisdb.me.uk/redmine/projects/haskell-sound-change stability: Alpha data-files: doc/HaSCDoc.pdf license-file: LICENSE library build-depends: base >= 4.3, containers >= 0.3, parsec >= 3, parallel >= 3.1, deepseq >= 1.1, mtl >= 1.1, transformers >= 0.2, text >= 0.10, text-icu >= 0.6.3, pretty >= 1, directory >= 1.1, filepath >= 1.2 hs-source-dirs: src exposed-modules: HaSC.IO.Disk, HaSC.IO.Memory, HaSC.Exec other-modules: HaSC.AST, HaSC.IO, HaSC.IdentMap, HaSC.Parse, HaSC.Regex, HaSC.Representation, HaSC.Transformations, HaSC.Search, HaSC.State executable HaSC GHC-Options: -rtsopts hs-source-dirs: src main-is: Main.hs 
+19
haskell cabal
Jul 15 2018-11-17T00:
source share
1 answer

In your executable section, add the library to Build-Depends so that the executable depends on the library.

However, there is a small problem: you must also move Main.hs executable file (and any other source files specific to the executable file) to another subdirectory and specify a different Hs-Source-Dirs so that it does not pick up library modules in the same folder .

 executable HaSC Build-Depends: HaSC Main-Is: Main.hs Hs-Source-Dirs: foo -- Directory you moved Main.hs to 

To do this, you need to specify Cabal-Version >= 1.8 . See ticket Cabal # 89 for details.

+20
Jul 15 2018-11-18T00:
source share
— -



All Articles