2015-10-01 14 views
1

我已經使用Cabal for GHC 7.10.2安裝了Vector包和REPA。運行這個程序:GHC 7.10.2 Data.Vector.Unboxed與REPA的衝突3.4.0.1

import qualified Data.Array.Repa as R 
import qualified Data.Vector.Unboxed as U 

main = print $ R.fromUnboxed (R.Z R.:. 16 R.:. 16) (U.replicate 10 0) 

我收到以下錯誤:

repa.hs:4:53: 
    Couldn't match expected type ‘vector-0.10.12.3:Data.Vector.Unboxed.Base.Vector 
            e0’ 
       with actual type ‘U.Vector a0’ 
    NB: ‘vector-0.10.12.3:Data.Vector.Unboxed.Base.Vector’ 
      is defined in ‘Data.Vector.Unboxed.Base’ 
       in package ‘vector-0.10.12.3’ 
     ‘U.Vector’ 
      is defined in ‘Data.Vector.Unboxed.Base’ 
       in package ‘vector-0.11.0.0’ 
    In the second argument of ‘R.fromUnboxed’, namely 
     ‘(U.replicate 10 0)’ 
    In the second argument of ‘($)’, namely 
     ‘R.fromUnboxed (R.Z R.:. 16 R.:. 16) (U.replicate 10 0)’ 

運行ghc-pkg list | grep vector,我注意到2個版本矢量包:

vector-0.10.12.3 
vector-0.11.0.0 
vector-th-unbox-0.2.1.2 

我跑ghc-pkg hide vector-0.10.12.3,並試圖重新編譯,但錯誤仍然存​​在。看起來vector-0.10.12.3已經安裝(是它的一部分?),但它並沒有暴露Data.Vector.Unboxed。我該如何解決這個問題?

回答

1

我認爲你需要隱藏其他版本。 GHCi似乎在拉動最近的可用版本的vector,這是而不是一個REPA是編譯針對。 stack因擅長避免這些問題而享有聲譽,但在您特別簡單的情況下,即使cabal也應該能夠弄清楚。您可能需要爲您的項目設置Cabal或Stack配置。