2015-02-08 79 views
2

我曾尝试以下:哈斯克尔模式与沙箱

cabal sandbox init 

然后进行以下小集团文件。

-- 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模式,或者我错过了一些步骤让他们工作?

+0

你确定你已经启用了interactive-haskell-mode hook吗?看来你正在使用劣质的haskell模式。 – Sibi 2015-02-08 18:41:26

+0

这个针对haskell模式的github问题可能会有帮助:https://github.com/haskell/haskell-mode/issues/253 – ErikR 2015-02-08 18:56:47

回答

1

请确保您有:

(add-hook 'haskell-mode-hook 'interactive-haskell-mode) 
在您的Emacs init文件

haskell-mode支持不同的GHCi process types。你需要一个使用cabal的人。

要了解当前应用的过程类型,请使用M-x describe-variable并输入haskell-process-type

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

因此,如果您的haskell-process-type设置为ghciauto,并且无法找到您的cabal沙箱,则会看到您发布的错误。如果它当前设置为ghci,加入改变haskell-process-typecabal-repl

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

到Emacs初始化文件并重新启动emacs的过程。

此外,您可以随时通过打开命令行,导航到包含.cabal文件的目录并输入cabal repl来确认问题是否特定于emacs。如果可行,那么你的cabal设置很好。

+0

我启用了interactive-haskell-mode并且haskell-process-type设置为ghci。有关如何继续查找错误的任何提示? – user3139545 2015-02-08 21:04:01

+0

因此,当我将haskell-process-type设置为cabal-repl时,它解决了大部分问题。然而,flycheck仍然在缓冲区中显示文本,说它无法找到该文件。任何冰如何让flycheck工作?同时将haskell-process-type设置为auto不起作用。 – user3139545 2015-02-08 21:22:10

+0

我认为这个链接应该有所帮助:https://github.com/flycheck/flycheck/issues/293#issuecomment-31580700。 – 2015-02-08 21:38:10