People ask me how to set up PureScript often, and while the majority of the people I talk to are already experienced with JS tooling (both in web and node), I've also run into plenty who haven't been exposed to either.
So in order to try to answer hundreds of people at once, I'll write some kind of "opinionated piece" that goes over some normal setup things you'll probably want.
And no, we're not going to use Bower, even though it works, because even I don't use Bower anymore, at home or at work.
Weird as it is, I have to get people to install Node >= 8 since many have outdated Node installations (often from apt), so please go install it as you will at least need it to run Pulp and your PureScript-Node programs: https://nodejs.org/en/download/
You CAN choose to not use Node at all when using PureScript. You'll just not be able to use Pulp (not a big deal) and you won't be able to run PureScript on Node (well, yeah)
The default npm config you get from most installations will give you some wonky setup where the workaround ends up being to
chown directories or run npm as
sudo. Please don't ever do these. What you actually want is to set your
.npmrc file to use a prefix:
npm set prefix ~/.npm
You'll then probably want to add the
bin directory to your PATH:
This is fairly optional, but you will probably want to have your project installed node_modules
.bin in your PATH also:
Unless you really dislike npm, unless you do work on the compiler or psc-package, you will probably not need much else than npm installed programs. So install these globally at first, and then choose whether or not you want to install these locally later:
npm i -g email@example.com pulp psc-package-bin-simple
Check that these work by trying some commands:
pulp --version psc-package
Just to save yourself the pain, you probably want to do something like
alias pp=psc-package, but this is up to you.
I use Spacemacs, Vim/Neovim, and VSCode. Using Atom or Sublime? There's notes on those too: https://github.com/purescript/documentation/blob/master/ecosystem/Editor-and-tool-support.md
Make a dir and cd into it like usual.
mkdir hello; cd hello
Important note here: Pulp currently still assumes you want to use Bower, but we don't. So you probably will want to alias the psc-package mode Pulp like so:
alias p=pulp --psc-package. Now init the project and try running it.
pulp --psc-package init; pulp run
If it doesn't flood you with compile messages and "Hello sailor!", then we have a problem. Otherwise, you have everything set up now. Now you can go on and write some web applications with Halogen or Node applications in whatever way you choose. This might be a good time for you to join the FP slack and ask people on #purescript and #purescript-beginners what kinds of things you should try doing. Sky's the limit!
At least, even if you choose not to use PureScript, now you can smugly correct people when they complain that "PureScript is tied to Bower" by telling them about how you could very well use Psc-Package or any custom approach to feeding source globs to the PureScript compiler.
- PureScript: http://purescript.org
- FP Slack: https://fpchat-invite.herokuapp.com
- Psc-Package: https://github.com/purescript/psc-package
- PureScript by Example: https://leanpub.com/purescript/read
- Getting Started with PureScript: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md