0

编辑:解决方案:该问题的解决方案是在 .cabal 文件中指定正确的向量库。标志(下面@Daniel 亲切地指出)是错误消息中引用了向量的确切版本。事实上,我的文件是针对 vector-0.10.something 构建的,而 vector-fftw 是针对 vector-0.9.1 编译的。


我正在尝试使用 fftw-vector 库,但遇到了这种类型的错误:

-- test.hs
import qualified Numeric.FFT.Vector.Invertible as FFTI
import qualified Data.Vector.Unboxed as U

z = FFTI.run FFTI.dct1 U.empty

main = putStrLn "Won't compile"

这是错误消息:

No instance for (vector-0.9.1:Data.Vector.Generic.Base.Vector
                   U.Vector Double)
  arising from a use of `FFTI.run'
Possible fix:
  add an instance declaration for
  (vector-0.9.1:Data.Vector.Generic.Base.Vector U.Vector Double)
In the expression: FFTI.run FFTI.dct1 U.empty
In an equation for `z': z = FFTI.run FFTI.dct1 U.empty

但据我所知,实际上有一个 Data.Vector.Gener.Base.Vector 的实例用于 Data.Vector.Unboxed Double (Link)(我猜我错了)。

这适用于 ghc-7.6.1、vector-0.9.1vector-fftw

(我必须对 vector-fftw 进行两个微小的更改,以便它与 base 4.6 和 ghc-7.6.1 一起编译,但这应该是无关的......)

谢谢你

编辑:

我对vector-fftw做了两个改动:

--- a/Numeric/FFT/Vector/Base.hsc
+++ b/Numeric/FFT/Vector/Base.hsc
@@ -34,10 +34,11 @@ import Control.Monad.Primitive (RealWorld,PrimMonad(..),
 import Control.Monad(forM_)
 import Foreign (Storable(..), Ptr, unsafePerformIO, FunPtr,
                 ForeignPtr, withForeignPtr, newForeignPtr)
-import Foreign.C (CInt, CUInt)
+-- import Foreign.C (CInt, CUInt)
 import Data.Bits ( (.&.) )
 import Data.Complex(Complex(..))
 import Foreign.Storable.Complex()
+import Foreign.C.Types



diff --git a/vector-fftw.cabal b/vector-fftw.cabal
index 5ca7c46..0436834 100644
--- a/vector-fftw.cabal
+++ b/vector-fftw.cabal
@@ -40,7 +40,7 @@ Library
   Other-modules:
         Numeric.FFT.Vector.Base

-  Build-depends: base>=4.3 && < 4.6, vector==0.9.*, primitive==0.4.*,
+  Build-depends: base>=4.3 && < 4.7, vector==0.9.*, primitive>=0.4 && < 0.6,
                  storable-complex==0.2.*
4

1 回答 1

2

Note that the error message specifies the specific version of the package that defines the class an instance is missing for:

No instance for (vector-0.9.1:Data.Vector.Generic.Base.Vector
                   U.Vector Double)

That usually means that one of the used packages was compiled against a different version than the one currently used in the project.

I don't see how exactly this would arise, but check for broken packages with ghc-pkg check, and verify that your packages have the correct ids with ghc-pkg describe vector and ghc-pkg describe vector-fftw, possibly vector was rebuilt after building vector-fftw. and the package hashes do not match.

于 2012-10-12T09:18:04.347 回答