使用 Haskell 工具栈初始化一个新的 GHCJS 项目

Initializing a new GHCJS project using the Haskell Tool Stack

使用 Haskell Stack 初始化 GHCJS 项目需要做什么?

stack documentation 之后,我正在尝试初始化一个 GHCJS 项目,以便我可以将 Haskell 代码编译为 JavaScript。

完成后 stack templates 我看到有一个 GHCJS 模板

ghcjs - Haskell to JavaScript compiler, based on GHC

当我尝试将新命令与此模板一起使用时:

stack new ghcjsSetup ghcjs

我收到此错误消息:

Downloading template "ghcjs" to create project "ghcjsSetup" in ghcjsSetup/ ...

The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /home/u/.stack/config.yaml, like this:
templates:
  params:
    author-email: value
    author-name: value
    category: value
    copyright: value
    github-username: value
Or you can pass each one as parameters like this:
stack new ghcjsSetup ghcjs -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- ghcjsSetup/ghcjsSetup.cabal

Selecting the best among 11 snapshots...

* Partially matches lts-9.11
    ghcjs-base not found
        - ghcjsSetup requires -any

Downloaded nightly-2017-11-01 build plan.    
Unable to parse cabal file: FromString "This package requires at least Cabal version 2.0" Nothing

我最近遇到了同样的错误。显然你有一个旧版本的 stack。您需要将其升级到版本 >= 1.5.1。发生此错误是因为我认为 Cabal ver. 2.0 中的某些文件格式发生了变化。