git.iko.soy/rowtype-yoga/purescm
on master help sign in
84 lines 2.4 kB history raw
1# purescm - Chez Scheme backend for PureScript
3## Installation
5Install requisites:
7* [`chezscheme`](https://cisco.github.io/ChezScheme/) - you should have the `scheme` command available in your `$PATH`.
8* [`libpcre2`](https://pcre2project.github.io/pcre2/) - `purescm` has a runtime dependency on the 16-bit variant of pcre2. Check your package manager for `pcre2` or `pcre2-16` or similar.
9* [`icu`](https://icu.unicode.org/) - `libicu` is used for locale-aware case conversions.
11You can install purescm with npm:
13```
14npm i --global purescm
15```
17## Usage
19The best way to use `purescm` is to use the [spago](https://github.com/purescript/spago) integration for alternative PureScript backends. In `spago.yaml` use the `backend` config like so:
21```
22workspace:
23 backend:
24 cmd: purescm
25 args:
26 - "build"
27```
29Then to compile your `purescm` project you can run:
31```
32spago build
33```
35This will produce output under `output/`. You can run the compiled program with:
37```
38purescm run
39```
41### Bundling
43Scheme files can be precompiled to a single Chez program:
45```
46purescm bundle-app
47```
49which generates a single file `output/main` which can be run with `scheme` or `petite`:
51```
52scheme --program output/main
53```
55## Development
57### Running the tests
59To run all tests, run `npm run test`. This will run both the scheme runtime unit tests and the snapshot tests.
61To overwrite old snapshots with the latest output, run `npm run test -- -a "--accept"`.
62To add a new snapshot, create a file called `Snapshot.X.purs` where `X` indicates what is being tested.
63If a snapshot needs a dependency, install it by running `cd test-snapshots && spago install <packages...>`.
65### Vendored Dependencies
67In order to represent `Array` and record types in `purescm`, the backend has a runtime dependency on implementation of SRFI 214 (Flexvectors). This is due in part to how [vectors](https://cisco.github.io/ChezScheme/csug9.5/objects.html#./objects:h5) are more like "arrays" than "array lists".
69We vendor [chez-srfi](https://github.com/arcfide/chez-srfi) using the following steps:
711. Clone `chez-srfi` at the project root.
732. Navigate to `chez-srfi` and run `./install.chezscheme.sps ../lib`.
753. To verify, simply invoke the Scheme REPL:
76```scheme
77$ scheme --libdirs ./lib:
78Chez Scheme Version 9.5.8
79Copyright 1984-2022 Cisco Systems, Inc.
81> (import (srfi :125))
83```