1

我想在 Mac 上使用 Atom 在 Haskell 中编程。因此,我在 Atom 中安装了以下软件包:

haskell-ghc-mod
ide-haskell
ide-haskell-cabal
language-haskell

之后我从这里安装了 Haskell 平台 8.2.1: https ://www.haskell.org/platform/#osx-none

这似乎不起作用,因为我无法编译,并且在每次启动 Atom 时都会出现以下错误消息:

Haskell-ghc-mod: ghc-mod failed to launch. It is probably missing or misconfigured. ENOENT

然后我尝试按照https://atom-haskell.github.io/installation/installing-binary-dependencies/中的描述手动安装必要的软件包,这也失败了(甚至取消注册失败):

Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ cabal install ghc-mod stylish-haskell

Resolving dependencies...
cabal: Could not resolve dependencies:
trying: ghc-mod-5.8.0.0 (user goal)
next goal: base (dependency of ghc-mod-5.8.0.0)
rejecting: base-4.10.0.0/installed-4.1... (conflict: ghc-mod => base<4.10 &&
>=4.6.0.1)
rejecting: base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0,
base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0,
base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1,
base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1
(constraint from non-upgradeable package requires installed instance)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, ghc-mod, syb
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ cabal uninstall ghc-mod stylish-haskell
cabal: This version of 'cabal-install' does not support the 'uninstall'
operation. It will likely be implemented at some point in the future; in the
meantime you're advised to use either 'ghc-pkg unregister ghc-mod' or 'cabal
sandbox hc-pkg -- unregister ghc-mod'.

Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ ghc-pkg unregister ghc-mod

ghc-pkg: cannot find package ghc-mod

Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ cabal sandbox hc-pkg -- unregister ghc-mod

ghc-pkg: cannot find package ghc-mod

Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ cabal install ghc-mod stylish-haskell

Resolving dependencies...
cabal: Could not resolve dependencies:
trying: ghc-mod-5.8.0.0 (user goal)
next goal: base (dependency of ghc-mod-5.8.0.0)
rejecting: base-4.10.0.0/installed-4.1... (conflict: ghc-mod => base<4.10 &&
>=4.6.0.1)
rejecting: base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0,
base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0,
base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1,
base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1
(constraint from non-upgradeable package requires installed instance)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, ghc-mod, syb
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox. 

我已经在 stackoverflow 中搜索了答案,但没有什么对我真正有用。谁能告诉我我错过了什么?

4

1 回答 1

2

我可以就问题的一部分给你建议。来自的错误消息cabal非常令人困惑,但它的意思是:

  • ghc-mod不适用于 4.10.0.0 版本的base
  • base随 GHC 一起提供,无法更改
  • GHC 8.2.1 附带基础 4.10.0.0
  • 因此:您无法ghc-mod使用您下载的 Haskell 平台版本进行构建

您可以通过下载较旧的 Haskell 平台 (8.0.2) 来解决此问题。在我看来:升级的 Haskell 平台版本为 8.2.1 还为时过早。

另一种方法是使用 Stack,它将为您管理 GHC 安装的安装。在这种情况下,运行stack install ghc-mod 应该可以正常工作。但是由于您仍将使用 Haskell 平台中的 GHC 8.2.1,因此它对您没有多大好处,因为 ghc-mod 与您的 GHC 版本相关联。

就个人而言:我从来没有成功设置过 ghc-mod。我也从未使用过 Atom 或 VS Code,但我听说有人分享了 VS Code + Haskero 的良好经验,所以如果你正在寻找类似 IDE 的体验,那可能值得考虑。我已经切换到使用 emacs+intero 模式,这可能需要考虑。

以下是一些可能有助于开始使用工具的链接:

于 2017-10-23T03:31:52.543 回答