install ghcjs from stack

2019-06-22 17:03发布

问题:

I have GHC installed through stack ( so that stack ghc -- --version shows 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

Some resources suggest ghcjs is somewhat experimental (though in the further stages).


Looking at http://docs.haskellstack.org/en/stable/ghcjs/ I thought maybe I could find stack.yaml and change it.

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

We are told to look at config.yaml which looks equally blank. Is this even right, am I going up a dead end?

$ 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
#
{}

I just want to install ghcjs with stack.

回答1:

Have a look at this page: http://docs.haskellstack.org/en/stable/ghcjs/

I would try:

  1. Start a new stack project, e.g. stack new js-test

  2. Modify the stack.yaml file by adding this stanza (taken from the above mentioned 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. Change the resolver: to lts-5.12 - this matches the above stanza.

  4. Run stack setup to get the compiler installed.

Step 4 will take a while.