问题
I have a Haskell library which exports several modules. I compile that library with both GHC
and GHCJS
. I'm using stack
to build the library. One of those modules depends on reflex-dom
. The issue is that I am not able to compile reflex-dom
on GHC due to not being able to link gtk+3
on OSX. As such, I'd like to exclude that library if the compiler is GHC
. How can I achieve that?
exposed-modules:
MyLib.Foo
MyLib.Bar
MyLib.App.Backend.Reflex
MyLib.App.Backend.Gloss
...
build-depends:
base ...
reflex-dom >= 0.2 && <0.3
回答1:
While you may not want to do this, the way to do this is described in the "configurations" section of the cabal user manual:
https://www.haskell.org/cabal/users-guide/developing-packages.html#configurations
In particular, you should be able to write the relevant sections as such:
exposed-modules:
MyLib.Foo
MyLib.Bar
MyLib.App.Backend.Reflex
MyLib.App.Backend.Gloss
if !impl(ghc)
exposed-modules:
OtherModule
build-depends: etc, etc, etc
if !impl(ghc)
build-depends: etc1, etc2
来源:https://stackoverflow.com/questions/34953338/how-can-i-have-a-conditional-on-cabal