【问题标题】:Need help on start using purescript on NixOS在 NixOS 上开始使用 purescript 需要帮助
【发布时间】:2018-02-16 01:37:17
【问题描述】:

我正在尝试在NixOs 上使用purescript 设置hello world 项目并且有几个问题,

  1. Official purescript 网站推荐通过npm 安装但没有nixos.nodePackages.purescript,而是我在nixpkgs 中找到了至少2 个变体
    • nixos.purescript
    • nixos.haskellPackages.purescript

有什么不同?

  1. 官网推荐pulpbower via npm,但只有nodePackages.bower可用,还有未记录的psc-package

nix 处理纯脚本包的方式应该是什么?

  1. 官方网站上的示例代码(见hello.purs bellow)甚至无法编译,

出现这些错误。

$ 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"

我将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.

正确的工作流程应该是怎样的?


我们的目标是拥有一个带有单个 hello.purs 的最小示例项目 在网络浏览器中运行。

这是hello.purs

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

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

main = log (greet "World")

如果您还可以为nix-shelldefault.nixnix-build 提供shell.nix,那将非常有帮助。

找到这个 2 岁的 guild,我正在尝试,但我仍然没有回答所有问题。

【问题讨论】:

标签: purescript nix nixos


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

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

【讨论】:

  • 嗨@Brian - 感谢您的回答!我是 NixOS 新手(刚刚下载了一张图片 ;-)),所以我想补充一些问题:你对这个项目有什么看法:github.com/ElvishJerricco/nix-purescriptPackages?我还有另一个更普遍的问题:你认为在 NixOS 上的 Purescript 体验中编码(正如你上面所描述的)比在其他操作系统上的开发有什么优势吗?
  • NixOS 没有很多 PureScript 支持,因此如果您只使用 PureScript 库和工具,您将不会获得大量好处。我可能会好很多,但我们需要花时间编写 Nix 代码来很好地支持 PureScript。我没用过,但是purescriptPackages是正确的方向:)
猜你喜欢
  • 2013-04-02
  • 1970-01-01
  • 2011-03-03
  • 2014-08-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-30
  • 2013-12-25
相关资源
最近更新 更多