Error running purescript example

妖精的绣舞 提交于 2020-01-06 05:50:15

问题


I'm trying to learn purescript starting with the simple "Hello World" from "Purescript by Example". Issuing a "pulp run" throws this error:

* Building project in /home/peter/devel/purescript/my-project
Error found:
at bower_components/purescript-psci-support/src/PSCI/Support.purs line     21, column 1 - line 21, column 1

  Unable to parse module:
  unexpected "else"
  expecting declaration or end of input

purs is of version 0.11.7, Pulp is version 12.2.0.

What am I doing wrong?

Thanks for your help.


回答1:


The recent release of PureScript 0.12 has introduced breaking changes. Several new package versions will not work on older compilers. If you want to stay pre-0.12, and you are using bower, then do this to your project:

  1. Delete all contents in the bower_components directory.
  2. Downgrade all package versions in bower.json to pre-0.12 versions, such as prelude 3.2.0, console 3.0.0, and psci-support 3.0.0. You can use Pursuit and look at older bower.json files on GitHub to figure out these versions.
  3. Run bower install.
  4. Run pulp build.

Alternatively, you can upgrade to 0.12 with PureScript Version Manager. At this time 0.12 is not available on npm. To do this you can follow these installation instructions but in short is:

  1. Uninstall the old compiler: npm uninstall -g purescript.
  2. Install PSVM: npm install -g psvm.
  3. Download 0.12: psvm install-latest.
  4. Install 0.12: psvm use v0.12.0
  5. Add PSVM's bin directory to your PATH which is C:\Users\<username>\.psvm\current\bin on Windows. Make sure your current session is updated with this new PATH variable.
  6. Test out the new compiler: purs --version.



回答2:


I'm working through PureScript by Example and ran into the same issue today. I stumbled across issue 3367, where gabejohnson directs us to the blog post, Working with 0.11.7 in a 0.12 world.

Long story short, it seems like PureScript 0.12 has introduced breaking changes, just like erisco said, and we should use psc-package instead of bower if we want to stay on 0.11.7 (because pulp doesn't work with PureScript 0.12 at the moment and bower is giving the team issues with dependency management).

You can install psc-package either with the binary or using npm install -g psc-package.

After that, you will need to tell pulp to use psc-package when you init a new project using pulp --psc-package init. Finally, install the lists package with psc-package install lists.

Keep in mind that packages do not have the purescript- prefix when using psc-package, so you just pass in the package name.

This is what got me back on track and I hope this helps you too.



来源:https://stackoverflow.com/questions/50540279/error-running-purescript-example

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!