In 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 are more like "arrays" than "array lists" and hashtables' canonical accessor, hashtable-ref
, takes a default
value rather than raising an exception.
We vendor chez-srfi using the following steps:
-
Clone
chez-srfi
at the project root. -
Navigate to
chez-srfi
and run./install.chezscheme.sps ../vendor
. This should produce ansrfi
folder inside ofvendor
. -
Copy the desired SRFIs from
vendor/srfi
intovendor/purs/runtime/srfi
. Make sure to also copy the SRFIs and other scheme files (e.g. the ones in theprivate
folder) that they depend on. The library-requirements function can aid in this process. -
Modify the copied scheme files such that the library names align with the folder structure.
sd
makes this easy!
sd "\(srfi " "(purs runtime srfi " vendor/purs/**/*.sls
- To verify, simply invoke the Scheme REPL:
$ scheme --libdirs ./vendor:
Chez Scheme Version 9.5.8
Copyright 1984-2022 Cisco Systems, Inc.
> (import (purs runtime srfi :125))
>
To run snapshots, run npm run test
.
To overwrite old snapshots with the latest output, run npm run test -- -a "--accept"
.
To add a new snapshot, create a file called Snapshot.X.purs
where X
indicates what is being tested.
If 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 purs-backend-chez
binary with unneeded dependencies.