squiggle/packages/squiggle-lang
2022-02-26 10:03:05 +11:00
..
__tests__ Merged with epic branch 2022-02-17 22:16:46 -05:00
dist ExpressionTree -> AST 2022-02-15 15:58:43 -05:00
src Minor program refactors 2022-02-18 17:14:35 -05:00
.gitignore Moving main repo to folder 2022-02-01 14:05:26 -05:00
bsconfig.json Foretold->Squiggle 2022-02-18 17:42:55 -05:00
jest.config.js Add typescript to squiggle-lang 2022-02-18 13:16:31 +11:00
package.json Add documentation and packaging info to lang 2022-02-26 10:03:05 +11:00
README.md Add documentation and packaging info to lang 2022-02-26 10:03:05 +11:00
shell.nix Moving main repo to folder 2022-02-01 14:05:26 -05:00
tsconfig.json Add documentation and packaging info to lang 2022-02-26 10:03:05 +11:00
yarn.lock Add typescript to squiggle-lang 2022-02-18 13:16:31 +11:00
yarn.nix Moving main repo to folder 2022-02-01 14:05:26 -05:00

Squiggle Language

Squiggle is a language for representing probability distributions, as well as functions that return probability distributions. Its original intended use is for improving epistemics around EA decisions.

This package, @squiggle/lang, contains the core language of squiggle. The main feature revolves around evaluating squiggle expressions. Currently the package only exports a single function, named "run", which from a squiggle string returns an object representing the result of the evaluation.

If using this package for tests or as a dependency, typescript typings are available and recommended to be used.

Building this package

This package doesn't have any dependencies on any other packages within the monorepo, so if you wish you can generally ignore lerna or yarn workspaces when dealing with this package in particular.

First, as per any node package, you will need to install dependencies, we recommend using yarn.

yarn

This package is mainly written in ReScript. But has a typescript interface.

ReScript has an interesting philosophy of not providing much in the way of effective build tools. Every ReScript file is compiled into a .bs.js file with the same name and same location, and then you can use these .bs.js files in other js files to create your program. To generate this .bs.js files to build the package, you run yarn build.

yarn build

You can also go yarn start for the purposes of watching for file changes and rebuilding every time there is one.

Finally, yarn test runs the current test suite over the language.

Distributing this package or using this package from other monorepo packages

If you would like to distribute this package, run yarn package to compile all the js and typescript into the dist directory. This dist directory code is what's referenced by other packages in the monorepo.

Using this package

The return type of this packages only experted function run is currently quite complicated, as it has to return either a number, or a distribution, or even a representation of a function of distributions. Currently the export is simply the generated type that rescript creates, and can be quite confusing. We therefore highly recommend the use of typescript when creating tests or using this package.