使用Numeric.FFT时没有(Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Vector Double)的实例

时间:2012-10-12 08:35:01

标签: haskell vector typeerror

编辑:解决方案:问题的解决方案是在.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.Unboxed Double (Link)实际上有一个Data.Vector.Gener.Base.Vector实例(猜我错了)。

这是ghc-7.6.1,vector-0.9.1vector-fftw

(我不得不对vector-fftw进行两处微小的改动,所以它用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.*

1 个答案:

答案 0 :(得分:2)

请注意,错误消息指定了包的特定版本,该版本定义了缺少实例的类:

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

这通常意味着其中一个使用的软件包是根据与项目当前使用的版本不同的版本编译的。

我不知道这是怎么出现的,但检查包含ghc-pkg check的已破坏的软件包,并验证您的软件包是否包含ghc-pkg describe vectorghc-pkg describe vector-fftw的正确ID,可能{在构建vector之后重建了{1}}。并且包装哈希值不匹配。