|
2 | 2 | title: How to build and run the Phrasebook examples
|
3 | 3 | ---
|
4 | 4 |
|
5 |
| -# Build tools |
6 |
| - |
7 | 5 | ## Haskell language server
|
8 | 6 |
|
9 | 7 | If you are using Visual Studio Code, we recommend installing the [Haskell](https://marketplace.visualstudio.com/items?itemName=haskell.haskell) extension. Error messages and other helpful annotations will then appear in the editor.
|
10 | 8 |
|
11 |
| -## Using Nix shell |
| 9 | +## ghcid |
| 10 | + |
| 11 | +If you are not using an editor with integrated language support, [ghcid](https://typeclasses.com/ghci/ghcid) is a good alternative. |
| 12 | + |
| 13 | +```sh |
| 14 | +$ ghcid --command 'cabal repl hello-world' |
| 15 | +``` |
12 | 16 |
|
13 |
| -You do not *have to* use Nix to run these Haskell programs, but you may find it convenient. |
| 17 | +## GHCi |
14 | 18 |
|
15 |
| -1. [Install Nix](https://nixos.org/nix/manual/#chap-installation) |
| 19 | +To open a REPL, use the "cabal repl" command, giving as an argument the name of the program you want to load. |
16 | 20 |
|
17 |
| -2. Install [Cachix](https://cachix.org/), and add the `typeclasses` cache. This step is optional, but will greatly reduce build time. |
| 21 | +```sh |
| 22 | +$ cabal repl hello-world |
| 23 | + |
| 24 | +λ> main |
| 25 | +hello world |
| 26 | +``` |
| 27 | + |
| 28 | +## Using Nix shell |
18 | 29 |
|
19 |
| - ```sh |
20 |
| - $ nix-env -iA 'cachix' -f 'https://cachix.org/api/v1/install' |
21 |
| - $ cachix use 'typeclasses' |
22 |
| - ``` |
| 30 | +You do not have to use Nix to run these Haskell programs, but you may find it convenient. |
23 | 31 |
|
24 |
| -3. Enter a Nix shell: |
| 32 | +[Install Nix](https://nixos.org/nix/manual/#chap-installation), |
25 | 33 |
|
26 |
| - ```sh |
27 |
| - $ nix-shell 'tools/shell.nix' |
28 |
| - ``` |
| 34 | +Optionally, install [Cachix](https://cachix.org/) and add the `typeclasses` cache. This step is optional, but will greatly reduce build time. |
29 | 35 |
|
30 |
| -4. Within the Nix shell, you have all of the dependencies required by the examples in the Phrasebook. For example, you can run commands like `runhaskell` and `ghcid`: |
| 36 | +```sh |
| 37 | +$ nix-env -iA 'cachix' -f 'https://cachix.org/api/v1/install' |
| 38 | +$ cachix use 'typeclasses' |
| 39 | +``` |
31 | 40 |
|
32 |
| - ```sh |
33 |
| - [nix-shell]$ ghc --version |
34 |
| - The Glorious Glasgow Haskell Compilation System, version 9.0.1 |
35 |
| - ``` |
| 41 | +Within the Nix shell, you have all of the dependencies required by the examples in the Phrasebook. For example, you can run commands like `runhaskell` and `ghcid`. |
36 | 42 |
|
37 |
| - ```sh |
38 |
| - [nix-shell]$ runhaskell 'hello-world.hs' |
39 |
| - hello world |
40 |
| - ``` |
| 43 | +```sh |
| 44 | +$ nix-shell 'tools/shell.nix' |
41 | 45 |
|
42 |
| - ```sh |
43 |
| - [nix-shell]$ ghcid --command 'ghci hello-world.hs' --test ':main' |
44 |
| - ``` |
| 46 | +[nix-shell]$ ghc --version |
| 47 | +The Glorious Glasgow Haskell Compilation System, version 9.0.1 |
| 48 | +``` |
45 | 49 |
|
46 | 50 | ## Outputs
|
47 | 51 |
|
|
0 commit comments