1

Is it possible to use cpp preprocessors with haskell stack,

e.g:

{-# LANGUAGE CPP #-}
module MyModule (
  main
  #ifdef TEST
    ,functionUnderTest
    ,functionAlsoUnderTest
  #endif
  ) where ....

with cabal, the following settings in .cabal appear to work: cpp-options: -DTEST is it possible to reproduce this with stack?

Thomas M. DuBuisson
  • 64,245
  • 7
  • 109
  • 166
Abraham P
  • 15,029
  • 13
  • 58
  • 126

1 Answers1

2

From the wiki, this answer here on SO and also this github issue

flags

Flags can be set for each package separately, e.g.

flags:   package-name:
    flag-name: true

Flags will only affect packages in your packages and extra-deps settings. Packages that come from the snapshot global database are not affected.

Alternatively you can pass a flag on directly when invoking stack with --flag, I assume the syntax would be something like

stack test --flag project:TEST
Community
  • 1
  • 1
epsilonhalbe
  • 15,637
  • 5
  • 46
  • 74