在NixOS上开始使用purescript需要帮助

wiz*_*zup 8 nixos purescript nix

我想安装hello world项目,purescriptNixOs和有对夫妇的问题,

  1. 官方 purescript网站建议安装通过,npm但没有nixos.nodePackages.purescript,相反,我找到至少2个变种nixpkgs
    • nixos.purescript
    • nixos.haskellPackages.purescript

有什么不同?

  1. 官方网站推荐pulpbower通过,npm但只有nodePackages.bower可用,并且没有证件psc-package.

应该nix如何处理purescript包?

  1. 官方网站上的示例代码(见下文hello.purs)甚至没有编译,

有这些错误.

$ purs compile hello.purs

Error found:
at hello.purs line 1, column 1 - line 1, column 1

Unable to parse module:
unexpected "import"
expecting "module"
Run Code Online (Sandbox Code Playgroud)

我添加module Hello到代码但仍然失败.

$ purs compile hello.purs 
Error 1 of 2:

  in module Hello
  at hello.purs line 2, column 1 - line 2, column 15

    Module Prelude was not found.
    Make sure the source file exists, and that it has been provided as an input to psc.


  See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
  or to contribute content related to this error.

Error 2 of 2:

  in module Hello
  at hello.purs line 3, column 1 - line 3, column 39

    Module Control.Monad.Eff.Console was not found.
    Make sure the source file exists, and that it has been provided as an input to psc.


  See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
  or to contribute content related to this error.
Run Code Online (Sandbox Code Playgroud)

应该如何正确的工作流程?


目标是hello.purs 在Web浏览器中运行一个最小的示例项目.

这是 hello.purs

module Hello where
import Prelude
import Control.Monad.Eff.Console (log)

greet :: String -> String
greet name = "Hello, " <> name <> "!"

main = log (greet "World")
Run Code Online (Sandbox Code Playgroud)

这将是非常有益的,如果你也可以提供shell.nixnix-shelldefault.nixnix-build.

发现这个2岁的公会,我正在尝试但我仍然没有回答我的所有问题.

Bri*_*nna 4

  1. nixos.purescript 只是 nixos.haskellPackages.purescript 的静态可执行文件;这会跳过将 PureScript 构建/安装为 Haskell 库
  2. 您可以通过安装 Pulp npm install pulp- 二进制文件将安装到node_modules/.bin/pulp
  3. 示例代码无法编译,因为您尚未通过 Bower 下载依赖项。您可以通过安装它们bower install purescript-prelude purescript-console

node_modules/.bin/pulp init会给你一个 Bower 文件,你可以运行bower install给你一个基本的项目。然后,您可以node_modules/.bin/pulp run使用 node.js 来执行它,但您可能想要pulp browserify --to example.js获取一个可以放入<script>HTML 标签中的文件。