【问题标题】:haskell-mode with sandboxes带沙箱的 haskell 模式
【发布时间】:2015-02-08 16:53:08
【问题描述】:

我尝试了以下方法:

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 模式是否不支持沙箱,或者我是否缺少一些步骤来让它们工作?

【问题讨论】:

  • 你确定你启用了 interactive-haskell-mode hook 吗?看来您使用的是劣质haskell-mode。
  • 这个关于 haskell-mode 的 github 问题可能会有所帮助:github.com/haskell/haskell-mode/issues/253

标签: haskell emacs haskell-mode


【解决方案1】:

确保你有:

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

在您的 emacs 初始化文件中。

haskell-mode 支持不同的GHCi process types。你需要一个使用阴谋集团的。

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

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

因此,如果您的 haskell-process-type 设置为 ghci 或 auto 并且无法找到您的阴谋集团沙箱,您将看到您发布的错误。如果当前设置为 ghci,请将 haskell-process-type 更改为 cabal-repl,并添加:

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

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

此外,您始终可以通过打开命令行、导航到包含 .cabal 文件的目录并输入 cabal repl 来确认问题是特定于 emacs 的。如果这样可行,那么您的阴谋集团就可以了。

【讨论】:

  • 我启用了交互-haskell-mode 并且 haskell-process-type 设置为 ghci。关于如何继续查找错误的任何提示?
  • 所以当我将 haskell-process-type 设置为 cabal-repl 时,它解决了大部分问题。然而,flycheck 仍然在缓冲区中的文本下划线,表示它无法找到该文件。任何冰如何让flycheck工作?将 haskell-process-type 设置为 auto 也不起作用。
  • 我认为这个链接应该有帮助:github.com/flycheck/flycheck/issues/293#issuecomment-31580700.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-28
相关资源
最近更新 更多