2

我尝试了以下方法:

cabal sandbox init

然后制作以下 cabal 文件。

-- Initial hsource.cabal generated by cabal init.  For further 
-- documentation, see http://haskell.org/cabal/users-guide/

name:                hsource
version:             0.1.0.0
-- synopsis:            
-- description:         
-- license:             
license-file:        LICENSE
author:              abc
maintainer:          abc
-- copyright:           
-- category:            
build-type:          Simple
-- extra-source-files:  
cabal-version:       >=1.10

executable hsource
  main-is:             main.hs
  other-modules:       
  -- other-extensions:    
  build-depends:       base >=4.7 && <4.8, csv
  hs-source-dirs:      src
  default-language:    Haskell2010

现在我安装 CSV 包:

cabal install --only-dependencies

现在当我尝试import Text.CSV然后C-c C-l我得到以下错误:

Util/RandomTree.hs:7:8-15: Could not find module ‘Text.CSV’ …
    Use -v to see a list of the files searched for.
Compilation failed.

所以我的问题是,haskell 模式是否不支持沙箱,或者我是否遗漏了一些让它们工作的步骤?

4

1 回答 1

1

确保你有:

(add-hook 'haskell-mode-hook 'interactive-haskell-mode)

在您的 emacs 初始化文件中。

haskell-mode 支持不同的GHCi 进程类型。你需要一个使用阴谋集团的。

要找出当前应用的流程类型,请使用M-x describe-variable并输入haskell-process-type

我认为 haskell-mode 文档已经过时了;因为,查看源代码,默认是,如果它能够找到.cabal-sandbox目录auto,它将使用它。否则,它将使用.cabal-replghci

因此,如果您haskell-process-type设置为ghciorauto并且无法找到您的 cabal 沙箱,您将看到您发布的错误。如果当前设置为,请通过添加以下内容ghci更改为haskell-process-typecabal-repl

(custom-set-variables
  '(haskell-process-type 'cabal-repl))

到您的 emacs 初始化文件并重新启动 emacs 进程。

此外,您始终可以通过打开命令行、导航到包含 .cabal 文件的目录并输入cabal repl. 如果可行,那么您的阴谋集团设置就可以了。

于 2015-02-08T19:13:20.923 回答