[Haskell-cafe] how to write cabal package file for executable with unit tests?
cobbe at ccs.neu.edu
Tue Feb 18 12:57:53 UTC 2014
On Mon, Feb 17, 2014 at 11:07:07AM +0100, Erik Hesselink wrote:
> Hi Richard,
> Where is your Parser module located?
The Happy source for the Parser module is in the src directory with the
rest of the files for the executable.
> Remember that your code will be compiled twice this way. What is, in
> my opinion, a better setup, is put the shared code in a library (like
> you had), and then have a shallow executable in the same package that
> depends on the library. The test-suite can then also depend on the
> library. All three should have distinct source dirs.
> Having most functionality in a library is a good design principle
> anyway: it makes it easier to re-use it in a different way later, and
> makes sure you think about API boundaries and such.
In principle, I agree. However, it's not obvious that there's actually any
code that's suitable for re-use in this case (except for stuff I've already
moved out to other libraries, in separate Cabal packages).
And I'm not sure that I get many of the benefits of thinking about API
boundaries, because I have to expose modules from the library if I want to
write unit tests for them, even if they're not really part of the library's
However, that seems to be the best way to go, so I'll leave it at that.
More information about the Haskell-Cafe