Squiggle 0.7.0

New functions, ESM Modules, a better Playground editor, several fixes

We’ve made several improvements to Squiggle recently. There are several minor/convenient language and library additions.

Several users have requested to be able to specify distributions based on 80th percentiles or 50th percentiles. Now you can write lines like,

normal({p10: 10, p90: 40})
lognormal({p25: 10, p75: 40})

If there’s interest in further flexibility, let us know. We could add this for all percentile combinations and provide similar support for other distributions.

One major technical change is that Squiggle is now built with ESM. This change significantly reduced our bundle size. There’s still a CommonJS build, but we’ll emphasize ESM over time.

Separately, the Playground now has syntax highlighting and supports autocomplete. Hopefully, this should make quick editing more painless.

Enjoy!

Full Changelog

The full changelog is here, but here’s the 0.7.0 part:

@quri/squiggle-lang

Language:

  • New functions: List.concat, List.uniq, List.append, List.flatten, List.join, Dict.mapKeys.
  • stdev and variance work for all kinds of distributions.
  • Support for ==, != and + on strings.
  • Support for trailing comma in arrays: arr = [5,6,] is now allowed.
  • Plot.fn allows for programmatical control of min..max range in charts.
  • Support for { p10: ..., p90: ... } and { p25: ..., p75: ... } in normal() and lognormal().
  • Non-integer key lookups in arrays are now disallowed; arr[1.5] and arr[3/0] will result in error; previously non-integer keys got rounded to 0 or the closest integer.
  • Fix for zero parameter function quirks; the checks are now stricter and some existing code might break.
  • Fix for normal(5,2) * 0 special case.
  • Fix for summary stats and inv function on pointMass distributions.
  • Fix for inv and sample on discrete distributions.

JS API:

  • sq function allows to embed Squiggle code in JS with syntax highlighting in VS Code (when VS Code extension is installed).
  • value.asJS() method for easier conversion of results to JS values.

Other:

  • ES6 modules build (we still provide CommonJS build as well).

@quri/squiggle-components

UI:

  • New code editor based on Codemirror, with the improved syntax highlighting and auto-completion for variables and stdlib functions.
  • Charts are now implemented in pure Canvas with D3 (instead of Vega), with some improvements in UI and rendering speed.

Other:

  • This package is now ESM-only! We depend on D3, and D3 is ESM-only, so squiggle-components has to be ESM-only as well. If your project still uses CommonJS and you doesn't use Next.js or other smart transpiler, you might encounter problems. See this document for advice.
  • Much smaller bundle size, thanks to removing some heavy dependencies.
  • oneLine prop in SquiggleEditor removed (probably no one used it).

Comments