Skip to content

Commit 4ba614e

Browse files
authored
Point to compiler's install guide (documentationjs#323)
* Add troubleshooting section Boosting heading sizes too so they're slightly larger than bold text. * Review feedback - move troubleshooting steps to install guide Related to purescript/purescript#3903 * Simplify installation instructions
1 parent ec3ae8e commit 4ba614e

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

guides/Getting-Started.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ Let's walk through the basics of getting set up to use the PureScript compiler `
44

55
We'll start with the installation of the compiler and Spago build tool, and then go through the basic usage of `purs repl`, working towards a solution of problem 1 from [Project Euler](http://projecteuler.net/problem=1).
66

7-
#### Installing the Compiler
7+
### Installing the Compiler
88

9-
You'll need to install [Node.js and npm](https://docs.npmjs.com/getting-started/installing-node). We recommend installing [Node.js and npm via a node version manager](https://docs.npmjs.com/getting-started/installing-node) to avoid issues with installing packages globally. If you choose to install it manually, you might experience the [`EACCES` error when installing packages globally](https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-1-change-the-permission-to-npm-s-default-directory).
9+
There are many [installation options](https://github.com/purescript/purescript/blob/master/INSTALL.md), but we recommend using `npm`.
10+
11+
[Install Node.js and npm via a node version manager](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-nodejs-and-npm). Using a node version manager helps avoid [`EACCES` errors](https://docs.npmjs.com/getting-started/fixing-npm-permissions) when installing packages globally (as we'll do in the next step).
1012

1113
Install the Purescript compiler (`purs`) with npm:
1214

@@ -16,9 +18,9 @@ Try running the PureScript compiler on the command line to verify that the PureS
1618

1719
purs
1820

19-
It can also be installed from [Hackage](http://hackage.haskell.org/package/purescript), or by downloading the latest [binary bundle](https://github.com/purescript/purescript/releases) for your OS. If you do so, make sure the `purs` executable is on your `$PATH`.
21+
If you encounter problems during installation, see the compiler's [Install Guide](https://github.com/purescript/purescript/blob/master/INSTALL.md) for troubleshooting suggestions.
2022

21-
#### Setting up the Development Environment
23+
### Setting up the Development Environment
2224

2325
[Spago](https://github.com/spacchetti/spago) is the recommended package manager and build tool for PureScript.
2426

@@ -54,15 +56,15 @@ You should see output similar to the following:
5456

5557
If everything was built successfully, and the tests ran without problems, then the last line should state "Tests succeeded."
5658

57-
#### Installing Dependencies
59+
### Installing Dependencies
5860

5961
Dependencies can be installed using Spago. We will be using the `lists` library shortly, so install it now:
6062

6163
spago install lists
6264

6365
The `lists` library sources should now be available in the `.spago/lists/{version}/` subdirectory, and will be included when you compile your project.
6466

65-
#### Working in PSCI
67+
### Working in PSCI
6668

6769
PSCi is the interactive mode of PureScript. It is useful for working with pure computations, and for testing ideas.
6870

@@ -117,7 +119,7 @@ We will be using some of the functions from the `Prelude` and `Data.List` module
117119

118120
Note that using `Tab` to autocomplete names can be a useful time-saving device in `psci`.
119121

120-
#### Solving Project Euler #1
122+
### Solving Project Euler #1
121123

122124
The following problem is taken from [Project Euler](http://projecteuler.net/problem=1):
123125

@@ -159,7 +161,7 @@ When you have finished using PSCi, type `:quit` to quit:
159161
> :quit
160162
See ya!
161163

162-
#### Compiling a Solution
164+
### Compiling a Solution
163165

164166
Now that we've seen how to use the REPL to reach the answer, let's move our solution into a source file and compile it.
165167

@@ -202,7 +204,7 @@ This will compile each module present in `src/` into a separate file in the `out
202204

203205
The compiler will display several warnings about missing type declarations. In general it is considered good practice to provide explicit type signatures. In this guide, they are left out for brevity. In the absence of type signatures, the PureScript compiler infers types automatically but will remind us to consider adding them.
204206

205-
#### Writing a Test Suite
207+
### Writing a Test Suite
206208

207209
To test our code, we'll use the `assert` library:
208210

@@ -226,7 +228,7 @@ Our "test suite" is just a single assertion that the `answer` value equals the c
226228

227229
Run the tests using `spago test`, and you should hopefully see "Tests OK" in the last line.
228230

229-
#### Creating Executables
231+
### Creating Executables
230232

231233
We can modify the `main` function in the `src/Main.purs` module to print our result to the console:
232234

@@ -249,7 +251,7 @@ The `spago run` command can be used to compile and run the `Main` module:
249251
The answer is 233168
250252

251253

252-
#### Compiling for the Browser
254+
### Compiling for the Browser
253255

254256
Spago can be used to turn our PureScript code into JavaScript suitable for use in the web browser by using the `spago bundle-app` command:
255257

@@ -310,7 +312,7 @@ This illustrates a few points about the way the PureScript compiler generates Ja
310312

311313
These points are important since they mean that PureScript generates simple, understandable code. The code generation process, in general, is quite a shallow transformation. It takes relatively little understanding of the language to predict what JavaScript code will be generated for a particular input.
312314

313-
#### Compiling CommonJS Modules
315+
### Compiling CommonJS Modules
314316

315317
Spago can also be used to generate CommonJS modules from PureScript code. This can be useful when using NodeJS, or just when developing a larger project which uses CommonJS modules to break code into smaller components.
316318

@@ -322,7 +324,7 @@ To build CommonJS modules, use the `spago build` command:
322324

323325
The generated modules will be placed in the `output` directory by default. Each PureScript module will be compiled to its own CommonJS module, in its own subdirectory.
324326

325-
#### What Next?
327+
### What Next?
326328

327329
If you're new to typed functional programming, your next stop should be [PureScript by Example](https://book.purescript.org/), which will walk you through learning PureScript by solving practical problems.
328330

0 commit comments

Comments
 (0)