- Add the repository directory to $PATH and $JSCHURCH_ROOT environment variables.
jschurch make
builds the Church compiler in Javascript.jschurch webservice
additionally combines all Javascript needed to run Church code (via scheme2js web service) into a single file.jschurch run filename.church
compiles filename.church to Javascript using the Church compiler generated by make, then runs the program using node.
To get access to the bher
and jschurch
command line tools and scheme libraries from any directory, cd
into the bher directory and type:
echo -e "\nexport PATH=`pwd`:\$PATH" >> ~/.bashrc
echo -e "\nexport IKARUS_LIBRARY_PATH=`pwd`:\$IKARUS_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc
Replace ~/.bashrc
with the path to your shell configuration file.
WEB INSTRUCTIONS
-
Pull latest version of https://github.com/LNFY/jschurch
-
Open "tests/param_test.church". This is a simple generative model that takes parameters that control the number of variables, sampling range, and constraint weight:
https://github.com/LNFY/jschurch/blob/master/tests/param_test.church
We define parameters by using the (lookup-param ...) function, which takes a type (int, float, or string), a parameter name, and a default value as an argument.
Note that these become command line parameters when running this with regular JSChurch (in node basically), in the order that lookup-param is called.
The last line is considered the "return value" of the program. If run in the browser, it is converted to JSON format.
-
To see how this actually works, go to the tests directory of the repository and issue
jschurch build param_test.church
. This creates fileparam_test.js
that can be run two ways:a. from the command line with node (with command line parameters in the order we called (lookup-param ...)). Try
node 10 11 12 0.01
(which sets the number of variables to 10, min and max to 11 and 12, and constraint penalty to 0.01.)b. in the browser. save
https://github.com/LNFY/jschurch/blob/master/tests/param_test.html
to the same directory as the compiled 'param_test.js' and open it in the browser. Inspect the source along with the JS debug console and the window itself. You'll see that we can run the Church program using run_church_main(), which will actually convert the "return value" of the program to JSON, and set the parameters we defined with (lookup-param ...) by updating a dictionary called church_params.