Update Getting Started for compiler v0.12.0

This commit is contained in:
Gabe Johnson 2018-06-06 21:35:42 -05:00
parent b53f81c19a
commit 504c5e0a88
2 changed files with 42 additions and 7 deletions

View file

@ -36,6 +36,7 @@ If you would prefer to use different terms, please use the section below instead
| [@chexxor](https://github.com/chexxor) | Alex Berg | [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/deed) |
| [@mattaudesse](https://github.com/mattaudesse) | Matt Audesse | [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/deed) |
| [@juhp](https://github.com/juhp) | Jens Petersen | [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/deed) |
| [@gabejohnson](https://github.com/gabejohnson) | Gabe Johnson | [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/deed) |
### Contributors using Modified Terms

View file

@ -44,6 +44,35 @@ You should see output similar to the following:
* Build successful. Running tests...
You should add some tests.
* Tests OK.
If you instead see error messages containing `Module Control.Monad.Eff was not found.` this is likely because the code
generated by `pulp init` is referencing the effect library widely used _before_ the release of the latest compiler (0.12.0) version.
To fix this error, change `src/Main.purs` and `test/Main.purs` to
```purescript
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = do
log "Hello sailor!"
```
and
```purescript
module Test.Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = do
log "You should add some tests."
```
Then try the commands again.
If everything was built successfully, and the tests ran without problems, then the last line should state "Tests OK".
@ -59,8 +88,11 @@ PSCi is the interactive mode of PureScript. It is useful for working with pure c
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.
PSCi, version 0.11.6
PSCi, version 0.12.0
Type :? for help
import Prelude
>
As the introduction indicates, you can type `:?` to see a list of commands:
@ -77,6 +109,7 @@ As the introduction indicates, you can type `:?` to see a list of commands:
:show import Show all imported modules
:show loaded Show all loaded modules
:paste paste Enter multiple lines, terminated by ^D
:complete <prefix> Show completions for <prefix> as if pressing tab
Further information is available on the PureScript documentation repository:
--> https://github.com/purescript/documentation/blob/master/guides/PSCi.md
@ -85,11 +118,12 @@ We will use a selection of these commands during this tutorial.
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.
To see the type of one of these values, first import the appropriate module using the `import` command. Then, use the `:type` command, followed by a space, followed by the name of the value:
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.
Next, use the `:type` command, followed by a space, followed by the name of the value:
> import Prelude
> :type map
forall a b f. (Prelude.Functor f) => (a -> b) -> f a -> f b
forall a b f. Functor f => (a -> b) -> f a -> f b
> import Data.List
> :type zip
@ -202,7 +236,7 @@ main = do
assert (answer == 233168)
```
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 `Eff` monad to compose multiple tests in our `main` function.
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.
Run the tests using `pulp test`, and you should hopefully see "Tests OK" in the last line.
@ -216,7 +250,7 @@ module Main where
import Prelude
import Euler (answer)
import Control.Monad.Eff.Console (log)
import Effect.Console (log)
main = do
log ("The answer is " <> show answer)
@ -231,7 +265,7 @@ The `pulp run` command can be used to compile and run the `Main` module:
#### What Next?
If you're new to typed functional programming, your next stop should be [PureScript by Example](https://leanpub.com/purescript/read), which will walk you through learning PureScript by solving practical problems.
If you're new to typed functional programming, your next stop should be [PureScript by Example](https://leanpub.com/purescript/read), which will walk you through learning PureScript by solving practical problems. (Note: At the time of writing, _Purescript by Example_ is compatible with the 0.11.x version of the compiler)
If you are already familiar with an ML-family language, like Haskell or Elm, PureScript by Example should still be appropriate as a starting point, but you may alternatively want to start by browsing the [language reference in the documentation repository](https://github.com/purescript/documentation/tree/master/language) instead. The language reference gives a more brief, reference-style description of the language, and is aimed at those who are already somewhat familiar with typed functional programming. There is also a [Differences from Haskell](https://github.com/purescript/documentation/blob/master/language/Differences-from-Haskell.md) page which Haskell programmers will find useful.