我尝试安装Haskell图表库,但无法安装其中一个依赖项。由于没有经历过haskell,我无法完全看到如何解决这个错误。
我删除了我认为与失败的构建(------ warnings ommitted (-Winvalid-pp-token) -----
)
[hsenv]➜ ~HSENV cabal install vector-space-0.8.5 Resolving dependencies... Downloading vector-space-0.8.5... Configuring vector-space-0.8.5... /var/folders/nq/fx4vf3v14jz9b8mldvcyv1xr0000gn/T/23218.c:1:12: warning: control reaches end of non-void function [-Wreturn-type] int foo() {} ^ 1 warning generated. Building vector-space-0.8.5... Preprocessing library vector-space-0.8.5... ------ warnings ommitted (-Winvalid-pp-token) ----- src/Data/VectorSpace.hs:4:3: error: invalid preprocessing directive #-} ^ ------ warnings ommitted (-Winvalid-pp-token) ----- 2 warnings and 1 error generated. Failed to install vector-space-0.8.5 cabal: Error: some packages failed to install: vector-space-0.8.5 failed during the building phase. The exception was: ExitFailure 1
答案 0 :(得分:3)
我认为你在安装了Xcode 5的OS X上?有instructions for that。
Xcode 5提供Clang作为C编译器,并且就预处理而言,它与GCC之间存在一些“解释差异”。这些差异可能会影响使用
CPP
扩展名的一些Haskell代码。使用Xcode 5的用户的另一种方法是安装GCC并指导GHC。有关说明,请参阅this page。
答案 1 :(得分:2)
正如Jon Purdy所说,这与预处理有关。特别是,vector-space
中的某些模块列出了所需的语言扩展列表,如下所示:
{-# LANGUAGE MultiParamTypeClasses, TypeOperators
, TypeFamilies, UndecidableInstances, CPP
, FlexibleContexts
#-}
{-# OPTIONS_GHC -Wall #-}
----------------------------------------------------------------------
-- |
-- Module : Data.VectorSpace
...
即。多个行{#- ... -#}
,因此分隔符是以#
开头的行。然后触发预处理器,显然没有好结果!
您可以将其更改为
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
或者也可能这样做:
{-# LANGUAGE MultiParamTypeClasses, TypeOperators
, TypeFamilies, UndecidableInstances, CPP
, FlexibleContexts #-}
这是一个自动执行此转换的脚本:
import System.IO.Strict as S
import System.Environment
import Control.Monad
rmLeadHash :: [String] -> [String]
rmLeadHash [] = []
rmLeadHash [l] = [l]
rmLeadHash (l:l':ls)
| ('#':_) <- dropWhile (==' ') l' = (l ++ l') : rmLeadHash ls
| otherwise = l : rmLeadHash (l':ls)
main = do
files <- getArgs
forM_ files $ \f -> do
hs <- S.readFile f
writeFile f $ unlines . rmLeadHash . lines $ hs
你可以这样做
$ git clone git://github.com/conal/vector-space.git # or cabal fetch vector-space
$ cd vector-space
$ cabal install strict # needed for my script
$ find src -name '*.hs' | xargs runhaskell remLeadingHashes.hs
# ^- the script I've posted
$ cabal install # installs the modified vector-space package
如果有效,您可能想推送更改。