尝试使用Repa包时不在范围错误

时间:2016-09-15 18:45:31

标签: haskell import repa

我对Haskell相对较新,我试图在项目中使用Repa包。我使用import qualified Data.Array.Repa as R在我的源代码中导入了包,但是当在ghci中加载Haskell文件时,我收到以下错误:

Location_repa.hs:46:26:
Not in scope: type constructor or class `D'
Perhaps you meant `R.D' (imported from Data.Array.Repa)

Location_repa.hs:46:29:
Not in scope: type constructor or class `Z'
Perhaps you meant `R.Z' (imported from Data.Array.Repa)

Location_repa.hs:46:30:
Illegal operator `:.' in type `Z :. (Dimension :: Int)'
Use TypeOperators to allow operators in types
.....

以下是使用Repa的源代码部分:

type CoordList = Array D (Z:. (Dimension::Int)) Integer

好像没有导入(加载)包。使用ghc-pkg list repa会产生以下结果:

C:/Program Files/Haskell Platform/7.10.2-a\lib\package.conf.d:
(no packages)
C:\Users\...\AppData\Roaming\ghc\x86_64-mingw32-7.10.2\package.conf.d:
repa-3.4.1.1

我该怎么办?

1 个答案:

答案 0 :(得分:3)

看起来你有两个问题。首先,您要导入合格的模块,但使用它不合格。您可以为您不想要符合条件的定义添加其他导入:

import Data.Array.Repa (D,Z,(:.))

第二个问题是第三条错误消息告诉你的。您需要启用TypeOperators扩展程序。把它放在文件的顶部:

{-# LANGUAGE TypeOperators #-}