从堆栈安装 ghcjs

install ghcjs from stack

我通过堆栈安装了 GHC(因此 stack ghc -- --version 显示 GHC-7.10.3)

$ stack install ghcjs

Run from outside a project, using implicit global project config
Using resolver: lts-5.2 from implicit global project's config file: /home/john/.stack/global-project/stack.yaml
The following target packages were not found: ghcjs

一些资源表明 ghcjs 在某种程度上是实验性的(尽管处于进一步的阶段)。


看着 http://docs.haskellstack.org/en/stable/ghcjs/ 我想也许我可以找到 stack.yaml 并更改它。

To use GHCJS with stack >= 0.1.8, place a GHCJS version in the compiler field of stack.yaml ... then stack setup

$ cat ~/.stack/global-project/stack.yaml
# This is the implicit global project's config file, which is only used when
# 'stack' is run outside of a real project.  Settings here do _not_ act as
# defaults for all projects.  To change stack's default settings, edit
# '/home/john/.stack/config.yaml' instead.
#
# For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration.html
#
flags: {}
extra-package-dbs: []
packages: []
extra-deps: []
resolver: lts-5.2

我们被告知要查看看起来同样空白的 config.yaml。这甚至是对的,我是在走死胡同吗?

$ cat ~/.stack/config.yaml
# This file contains default non-project-specific settings for 'stack', used
# in all projects.  For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration.html
#
{}

我只想用堆栈安装ghcjs

看看这个页面:http://docs.haskellstack.org/en/stable/ghcjs/

我会尝试:

  1. 开始一个新的堆栈项目,例如stack new js-test

  2. 修改 stack.yaml 文件,添加以下节(取自上述 link):

    compiler: ghcjs-0.2.0.20160414_ghc-7.10.3
    compiler-check: match-exact
    setup-info:
      ghcjs:
        source:
          ghcjs-0.2.0.20160414_ghc-7.10.3:
            url: https://s3.amazonaws.com/ghcjs/ghcjs-0.2.0.20160414_ghc-7.10.3.tar.gz
            sha1: 6d6f307503be9e94e0c96ef1308c7cf224d06be3
    
  3. resolver: 更改为 lts-5.12 - 这与上面的节匹配。

  4. 运行 stack setup 安装编译器。

第 4 步需要一段时间。