Need help getting started with purescript on NixOS

I am trying to set up a hello world project with purescript on NixOs and ask a couple of questions,

  • The official purescript website recommends installing through npm , but there is no nixos.nodePackages.purescript , instead there are at least 2 options that I found in nixpkgs
    • nixos.purescript
    • nixos.haskellPackages.purescript

What are different?

  1. The official site recommends pulp and bower via npm , but only nodePackages.bower is available and the psc-package is not documented.

What should be the nix way to handle purescript packages?

  1. The sample code on the official website (see hello.purs below) does not even compile,

with this error.

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

I am adding module Hello to the code, but still failed.

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

How should the correct workflow be?


The goal is to have a minimal sample project with one hello.purs running in a web browser.

This is hello.purs

 module Hello where import Prelude import Control.Monad.Eff.Console (log) greet :: String -> String greet name = "Hello, " <> name <> "!" main = log (greet "World") 

It would be very helpful if you can also provide shell.nix for nix-shell or default.nix for nix-build .

The guild found this for 2 years, I try, but I still do not have the answer to all my questions.

+5
source share
1 answer
  • nixos.purescript - these are only static executables for nixos.haskellPackages.purescript; this skips creating / installing PureScript as a Haskell library.
  • You can install Pulp via npm install pulp - the binary will be installed on node_modules/.bin/pulp
  • The sample code does not compile because you did not download the dependencies through Bower. You can install them through bower install purescript-prelude purescript-console .

But node_modules/.bin/pulp init will provide you with a Bower file, and you can run bower install to give you a basic project. You can then execute node_modules/.bin/pulp run to execute it using node.js, but you probably want pulp browserify --to example.js to get a file that you can put in the <script> in HTML.

+2
source

Source: https://habr.com/ru/post/1271599/


All Articles