How can I have a conditional on cabal?

做~自己de王妃 提交于 2019-12-11 10:19:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!