v0.2.8: fromSamples and jsImports

This commit is contained in:
Quinn Dougherty 2022-04-30 11:33:03 -04:00
parent 9464aea6fa
commit 9fe7034c51
3 changed files with 21 additions and 3 deletions

View File

@ -3,6 +3,21 @@
# Squiggle language # Squiggle language
## Use the `npm` package
For instance, in a fresh `create-react-app`, you can
```sh
yarn add @quri/squiggle-lang
```
```js
import {run} from '@quri/squiggle-lang';
run("normal(0, 1) * fromSamples([-3,-2,-1,1,2,3,3,3,4,9]").value.value.toSparkline().value)
```
**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`.
## Build for development ## Build for development
We assume that you ran `yarn` at the monorepo level. We assume that you ran `yarn` at the monorepo level.

View File

@ -1,6 +1,6 @@
{ {
"name": "@quri/squiggle-lang", "name": "@quri/squiggle-lang",
"version": "0.2.7", "version": "0.2.8",
"homepage": "https://squiggle-language.com", "homepage": "https://squiggle-language.com",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
@ -24,6 +24,7 @@
"format:rescript": "rescript format -all", "format:rescript": "rescript format -all",
"format:prettier": "prettier --write .", "format:prettier": "prettier --write .",
"format": "yarn format:rescript && yarn format:prettier", "format": "yarn format:rescript && yarn format:prettier",
"prepack": "yarn build && yarn test && yarn bundle",
"all": "yarn build && yarn bundle && yarn test" "all": "yarn build && yarn bundle && yarn test"
}, },
"keywords": [ "keywords": [
@ -35,7 +36,7 @@
"rescript": "^9.1.4", "rescript": "^9.1.4",
"jstat": "^1.9.5", "jstat": "^1.9.5",
"pdfast": "^0.2.0", "pdfast": "^0.2.0",
"mathjs": "10.5.0" "mathjs": "^10.5.0"
}, },
"devDependencies": { "devDependencies": {
"bisect_ppx": "^2.7.1", "bisect_ppx": "^2.7.1",
@ -61,6 +62,7 @@
"webpack-cli": "^4.9.2" "webpack-cli": "^4.9.2"
}, },
"source": "./src/js/index.ts", "source": "./src/js/index.ts",
"browser": "./dist/bundle.js",
"main": "./dist/src/js/index.js", "main": "./dist/src/js/index.js",
"types": "./dist/src/js/index.d.ts" "types": "./dist/src/js/index.d.ts"
} }

View File

@ -189,7 +189,8 @@ let rec run = (~env, functionCallInfo: functionCallInfo): outputType => {
->GenericDist.mixture(~scaleMultiplyFn=scaleMultiply, ~pointwiseAddFn=pointwiseAdd) ->GenericDist.mixture(~scaleMultiplyFn=scaleMultiply, ~pointwiseAddFn=pointwiseAdd)
->E.R2.fmap(r => Dist(r)) ->E.R2.fmap(r => Dist(r))
->OutputLocal.fromResult ->OutputLocal.fromResult
| FromSamples(xs) => xs | FromSamples(xs) =>
xs
->SampleSetDist.make ->SampleSetDist.make
->E.R2.errMap(x => DistributionTypes.SampleSetError(x)) ->E.R2.errMap(x => DistributionTypes.SampleSetError(x))
->E.R2.fmap(x => x->DistributionTypes.SampleSet->Dist) ->E.R2.fmap(x => x->DistributionTypes.SampleSet->Dist)