time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (2679B)


      1 [![npm version](https://badge.fury.io/js/@quri%2Fsquiggle-lang.svg)](https://www.npmjs.com/package/@quri/squiggle-lang)
      2 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/quantified-uncertainty/squiggle/blob/main/LICENSE)
      3 
      4 # Squiggle language
      5 
      6 _An estimation language_
      7 
      8 # Use the `npm` package
      9 
     10 For instance, in a javascript project, you can
     11 
     12 ```sh
     13 npm add @quri/squiggle-lang # or `yarn add`, or `pnpm add`
     14 ```
     15 
     16 The `@quri/squiggle-lang` package exports a single function, `run`, which given
     17 a string of Squiggle code, will execute the code and return any exports and the
     18 environment created from the squiggle code.
     19 
     20 ```js
     21 import { run, defaultEnvironment } from "@quri/squiggle-lang";
     22 run(
     23   "normal(0, 1) * SampleSet.fromList([-3, 2,-1,1,2,3,3,3,4,9])"
     24 ).result.value.value.toSparkline(defaultEnvironment).value;
     25 ```
     26 
     27 **However, for most use cases you'll prefer to use our [library of React components](https://www.npmjs.com/package/@quri/squiggle-components)**, and let your app transitively depend on `@quri/squiggle-lang`.
     28 
     29 `run` has two optional arguments. The first optional argument allows you to set
     30 sampling settings for Squiggle when representing distributions. The second optional
     31 argument allows you to pass an environment configuration that allows you to control
     32 distribution settings.
     33 
     34 The return type of `run` is a bit complicated. We highly recommend using typescript
     35 when using this library to help navigate the return type.
     36 
     37 # Build for development
     38 
     39 We assume that you installed turborepo and ran `pnpm i`.
     40 
     41 ```sh
     42 npx turbo build
     43 ```
     44 
     45 Other:
     46 
     47 ```sh
     48 pnpm dev  # listens to files and recompiles at every mutation
     49 pnpm test
     50 
     51 # where o := open in osx and o := xdg-open in linux,
     52 pnpm coverage:local; o coverage/lcov-report/index.html  # produces coverage report and opens it in browser
     53 ```
     54 
     55 # Distributing this package or using this package from other monorepo packages
     56 
     57 As it says in the other `packages/*/README.md`s, building this package is an essential step of building other packages.
     58 
     59 # Information
     60 
     61 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.
     62 
     63 This package, `@quri/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.
     64 
     65 If using this package for tests or as a dependency, typescript typings are available and recommended to be used.