0

我对 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

我应该怎么办?

4

1 回答 1

3

It looks like you have two problems. First, you're importing the module qualified, but using it unqualified. You can add an additional import for definitions that you don't want to have to qualify:

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

The second problem is what the third error message is telling you. You need to turn on the TypeOperators extension. Put this at the top of your file:

{-# LANGUAGE TypeOperators #-}
于 2016-09-15T19:36:08.923 回答