You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update getting started guide to use spago
* Update spago test output
* Fix wording for spago test output.
Co-Authored-By: Thomas Honeyman <[email protected]>
Co-authored-by: Thomas Honeyman <[email protected]>
Copy file name to clipboardExpand all lines: guides/Getting-Started.md
+29-28Lines changed: 29 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Let's walk through the basics of getting set up to use the PureScript compiler `purs`, and its interactive mode `purs repl`.
4
4
5
-
We'll start with the installation of the compiler and Pulp 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).
5
+
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).
6
6
7
7
#### Installing the Compiler
8
8
@@ -16,48 +16,49 @@ The Purescript compiler (`purs`) can be installed with npm:
16
16
17
17
#### Setting up the Development Environment
18
18
19
-
PureScript's core libraries are configured to use the [Pulp](https://github.com/purescript-contrib/pulp) build tool, and packages are available in the [Bower registry](http://bower.io/search/?q=purescript-).
19
+
PureScript's core libraries are configured to use the [Spago](https://github.com/spacchetti/spago) package manager and build tool.
20
20
21
-
If you don't have Pulp and Bower installed, install them now:
21
+
If you don't have Spago installed, install it now:
22
22
23
-
npm install -g pulp bower
23
+
npm install -g spago
24
24
25
-
Create a new project in an empty directory using `pulp init`:
25
+
Create a new project in an empty directory using `spago init`:
26
26
27
-
pulp init
27
+
spago init
28
28
29
29
Your directory should now contain the following files:
30
30
31
-
-`bower.json` - contains library dependency information
32
-
-`bower_components/` - a directory for installed dependencies
31
+
-`packages.dhall` - contains Spago configuration
32
+
-`spago.dhall` - contains library dependency information
33
33
-`src/Main.purs` - Entry point module for your project
34
34
-`test/Main.purs` - An empty test suite
35
35
36
36
At this point, you should be able to build the project and run the tests:
37
37
38
-
pulp build
39
-
pulp test
38
+
spago build
39
+
spago test
40
40
41
41
You should see output similar to the following:
42
42
43
-
* Building project in /Users/paf31/Documents/Code/purescript/pulp-test
44
-
* Build successful. Running tests...
43
+
[info] Installation complete.
44
+
[info] Build succeeded.
45
+
🍝
45
46
You should add some tests.
46
-
* Tests OK.
47
-
48
-
If everything was built successfully, and the tests ran without problems, then the last line should state "Tests OK".
47
+
[info] Tests succeeded.
48
+
49
+
If everything was built successfully, and the tests ran without problems, then the last line should state "Tests succeeded."
49
50
50
51
#### Installing Dependencies
51
52
52
-
Dependencies can be installed using Bower. We will be using the `purescript-lists` library shortly, so install it now:
53
+
Dependencies can be installed using Spago. We will be using the `purescript-lists` library shortly, so install it now:
53
54
54
-
bower install purescript-lists --save
55
+
spago install lists
55
56
56
57
#### Working in PSCI
57
58
58
59
PSCi is the interactive mode of PureScript. It is useful for working with pure computations, and for testing ideas.
59
60
60
-
Open PSCi by typing `pulp repl` at the command line. Pulp will create a file in your directory called `.purs-repl`, which contains instructions to PSCi to load your modules and dependencies. If you invoke the PSCi executable directly, you would need to load these files by hand.
61
+
Open PSCi by typing `spago repl` at the command line. Optionally, you can create a file in your directory called `.purs-repl`, which contains instructions to PSCi to load your modules and dependencies. If you invoke the PSCi executable directly, you would need to load these files by hand.
61
62
62
63
PSCi, version 0.12.0
63
64
Type :? for help
@@ -89,10 +90,11 @@ We will use a selection of these commands during this tutorial.
89
90
90
91
Start by pressing the Tab key to use the autocompletion feature. You will see a collection of names of functions from the Prelude which are available to use.
91
92
92
-
To see the type of one of these values, first import the appropriate module using the `import` command.`pulp init` configures `.purs-repl` to install `Prelude` automatically, so you won't have to do it yourself.
93
+
To see the type of one of these values, first import the appropriate module using the `import` command.
93
94
94
95
Next, use the `:type` command, followed by a space, followed by the name of the value:
95
96
97
+
> import Prelude
96
98
> :type map
97
99
forall a b f. Functor f => (a -> b) -> f a -> f b
98
100
@@ -172,16 +174,16 @@ answer = sum multiples
172
174
173
175
It is possible to load this file directly into the REPL and to continue working:
174
176
175
-
pulp repl
177
+
spago repl
176
178
> import Euler
177
179
> answer
178
180
233168
179
181
> :quit
180
182
See ya!
181
183
182
-
Alternatively, we can use Pulp to compile our new module to JavaScript:
184
+
Alternatively, we can use Spago to compile our new module to JavaScript:
183
185
184
-
pulp build
186
+
spago build
185
187
186
188
This will compile each module present in `src/` into a separate file in the `output/` directory.
187
189
@@ -191,7 +193,7 @@ The compiler will display several warnings about missing type declarations. In g
191
193
192
194
To test our code, we'll use the `purescript-assert` library:
193
195
194
-
bower i purescript-assert --save
196
+
spago install assert
195
197
196
198
Modify the `test/Main.purs` file, and add the following code:
197
199
@@ -209,7 +211,7 @@ main = do
209
211
210
212
Our "test suite" is just a single assertion that the `answer` value equals the correct integer. In a real test suite, we might use the `Effect` monad to compose multiple tests in our `main` function.
211
213
212
-
Run the tests using `pulp test`, and you should hopefully see "Tests OK" in the last line.
214
+
Run the tests using `spago test`, and you should hopefully see "Tests OK" in the last line.
213
215
214
216
#### Creating Executables
215
217
@@ -227,11 +229,10 @@ main = do
227
229
log ("The answer is " <> show answer)
228
230
```
229
231
230
-
The `pulp run` command can be used to compile and run the `Main` module:
232
+
The `spago run` command can be used to compile and run the `Main` module:
0 commit comments