1# purescm - Chez Scheme backend for PureScript
6npm i --global purescm@next
11The 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:
21Then to compile your `purescm` project you can run:
27This will produce output under `output/`. You can run the compiled program with:
35Scheme files can be precompiled to a single Chez program:
41which generates a single file `output/main` which can be run with `scheme` or `petite`:
44scheme --program output/main
47## Vendored Dependencies
49In order to represent `Array` and record types in `purescm`, the backend has a runtime dependency on implementations of SRFI 214 (Flexvectors) and SRFI 125 (Intermediate hash tables). 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" and [hashtables](https://cisco.github.io/ChezScheme/csug9.5/objects.html#./objects:h12)' canonical accessor, `hashtable-ref`, takes a `default` value rather than raising an exception.
51We vendor [chez-srfi](https://github.com/arcfide/chez-srfi) using the following steps:
531. Clone `chez-srfi` at the project root.
552. Navigate to `chez-srfi` and run `./install.chezscheme.sps ../vendor`. This should produce an `srfi` folder inside of `vendor`.
573. Copy the desired SRFIs from `vendor/srfi` into `vendor/purs/runtime/srfi`. Make sure to also copy the SRFIs and other scheme files (e.g. the ones in the `private` folder) that they depend on. The [library-requirements](https://cisco.github.io/ChezScheme/csug9.5/libraries.html#./libraries:h7) function can aid in this process.
594. Modify the copied scheme files such that the library names align with the folder structure. [`sd`](https://github.com/chmln/sd) makes this easy!
61sd "\(srfi " "(purs runtime srfi " vendor/purs/**/*.sls
645. To verify, simply invoke the Scheme REPL:
66$ scheme --libdirs ./vendor:
67Chez Scheme Version 9.5.8
68Copyright 1984-2022 Cisco Systems, Inc.
70> (import (purs runtime srfi :125))
76To run snapshots, run `npm run test`.
77To overwrite old snapshots with the latest output, run `npm run test -- -a "--accept"`.
78To add a new snapshot, create a file called `Snapshot.X.purs` where `X` indicates what is being tested.
79If a snapshot needs a dependency, install it by running `spago -x test-snapshots/spago.dhall install <packages...>`. The snapshots have their own `spago.dhall` file so as not to pollute the `purescm` binary with unneeded dependencies.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list