[英]No instance for (Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Vector Double) when using Numeric.FFT
EDIT: Solution : The solution to the problem was to specify the correct vector library in a .cabal file. 编辑:解决方案 :问题的解决方案是在.cabal文件中指定正确的矢量库。 The tell-tale sign (kindly pointed out by @Daniel below) was that the exact version of the vector was referenced in the error message.
告诉标志(由下面的@Daniel友情指出)是错误消息中引用了向量的确切版本 。 Indeed my file was building against vector-0.10.something while vector-fftw was compiled against vector-0.9.1.
事实上,我的文件是针对vector-0.10.something构建的,而vector-fftw是针对vector-0.9.1编译的。
I am trying to use the fftw-vector library but am stuck with this type error: 我正在尝试使用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"
This is the error message: 这是错误消息:
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
but as far as I can tell there is actually an instance of Data.Vector.Gener.Base.Vector for Data.Vector.Unboxed Double (Link) (guess I am wrong). 但据我所知,实际上有一个Data.Vector.Gener.Base.Vector的实例,用于Data.Vector.Unboxed Double (Link) (猜我错了)。
This is with ghc-7.6.1, vector-0.9.1 and vector-fftw . 这与ghc-7.6.1, vector-0.9.1和vector-fftw有关 。
(I had to make two tiny changes to vector-fftw so it compiles with base 4.6 and ghc-7.6.1, but that should be unrelated ...) (我不得不对vector-fftw进行两处微小的改动,所以用基础4.6和ghc-7.6.1编译,但这应该是不相关的......)
thank you 谢谢
EDIT: 编辑:
two changes I made to vector-fftw: 我对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.*
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
. 我不知道究竟会出现这种情况,但是用
ghc-pkg check
是否检查了破损的包,并使用ghc-pkg describe vector
和ghc-pkg describe vector-fftw
验证你的包是否具有正确的ID,可能是vector
已重建在构建vector-fftw
。 and the package hashes do not match. 和包哈希不匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.