squiggle icon indicating copy to clipboard operation
squiggle copied to clipboard

Serialize AST with normalization

Open berekuk opened this issue 1 year ago • 2 comments

This PR implements the proper serialization of AST - the part that was missing from #3158.

AST is already JSON-compatible, so in #3158 I didn't normalize it. That could cause N^2 amount of JSON when we serialized expressions.

Pseudo-code example:

expression: {
  type: "Call",
  fn: ...,
  arg1: { // this is a nested expression
    ...,
    ast: ast1, // this is AST for the nested expression
  },
  arg2: {
    ...,
    ast: ast2,
  },
  ast: { // this is AST for the outer expression
    type: "Call",
    arg1: ast1, // as you can see, ast1 is duplicated
    arg2: ast2,
  }

This branch is done on top of #3268, for merging convenience.

PS: The reduction of expression-related data in the produced JSON bundle, in case of GUCEM codebase, is at least 2x (but might be 5x, hard to tell exactly).

berekuk avatar May 21 '24 15:05 berekuk

🦋 Changeset detected

Latest commit: 8a7332b4b0246cf0aea39cfe0a01775dff84e8e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@quri/squiggle-lang Patch
@quri/squiggle-components Patch
@quri/prettier-plugin-squiggle Patch
@quri/versioned-squiggle-components Patch
vscode-squiggle Patch
@quri/squiggle-textmate-grammar Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar May 21 '24 15:05 changeset-bot[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

4 Ignored Deployments
Name Status Preview Updated (UTC)
quri-hub ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 3:22pm
quri-ui ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 3:22pm
squiggle-components ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 3:22pm
squiggle-website ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 3:22pm

vercel[bot] avatar May 21 '24 15:05 vercel[bot]