[英]cabal, module and dependencies
我想知道,當您通過cabal下載並安裝軟件包時,cabal會嘗試構建所有內容還是僅構建您需要的內容。 例如,許多軟件包包括和HaskellTemplate模塊,這些模塊顯然需要HaskellTemplate擴展。 如果您使用不支持此擴展的編譯器,但由於無論如何都不會使用該模塊而並不在意該模塊,會發生什么?
當您從黑客那里cabal install
軟件包時,cabal也需要安裝該軟件包的所有依賴項。
通常,包中的所有文件都會被編譯。 但是,有一些例外情況:
為了說明第2點,請考慮以下包定義:
name: foo
version: 0.1
flag withGHC
default: True
manual: False # Allow cabal to figure out the correct value for the flag automatically
library
exposed-modules:
Foo.Bar # This will always be compiled
if flag(withGHC)
build-depends: ghc
exposed-modules:
Foo.GHC # This will only be compiled when withGHC is True
現在,當您在GHC下安裝foo
時,cabal將發現即使啟用了該標志,它也可以滿足依賴關系,因此將構建Foo.GHC
。
但是,如果嘗試使用其他編譯器安裝foo
,cabal將在使用withGHC = True
選擇時看到,這會導致ghc
依賴關系,它不能滿足要求。 因此,它將選擇withGHC = False
,並且不會構建Foo.GHC
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.