Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial api for "getTree" #176

Closed
brprice opened this issue Oct 18, 2021 · 1 comment · Fixed by #180
Closed

Initial api for "getTree" #176

brprice opened this issue Oct 18, 2021 · 1 comment · Fixed by #180
Assignees
Labels
enhancement New feature or request

Comments

@brprice
Copy link
Contributor

brprice commented Oct 18, 2021

Description

This is a feature request.

We need to return program trees from our api. In particular, to get the current program.

NB This FR is intentionally very basic, and does not worry about what information about the current program will be needed by a frontend. The purpose is to get something working to iterate on. We will flesh out more details (in a separate issue) after implementing the "0.1" version, when I have a better perspective and this task is out of the critical path.

Dependencies

None.

Spec

We don't want to expose the full complexity of our AST to a frontend, as it is mostly not needed for rendering purposes (and that is all the frontend should be doing).

We just send the skeleton of the tree, with an (ID, Text) decoration on each node. This Text is unspecified here, but is only to have something non-trivial to work with, and to make implementation/debugging easier.

The format of this data is as a literal rose tree in JSON

  • Each node is of the form { id:3, label:"some-text", children: [...]}
  • The children are nested occurrences of nodes
  • Thus the tree will always be non-empty
  • e.g. {id:0,desc:"root", children: [{id:1, label:"child",children:[]}]}

Implementation details

Previously, "all" our endpoints returned Result ProgError _. Since getting the current program can never fail, should we make this explicit in the API? For the 0.1 let's take the easy path and keep the error possibility.

A different representation would be to "flatten": use the ids as keys and explicitly list children and parents by id. E.g.

{existant:[0,1],
 nodes:{
    "0": {desc:"root",children:[1],parent:null},
    "1": {desc:"child", children:[], parent:0}
  }
 }

It would be worth thinking about which representation is most useful from a frontend-implementors point of view. However, for the sake of a 0.1 I shall do the literal-rose-tree thing.

Not in spec

In the future we will want to be able to represent diffs of trees compactly. This is both for network efficiency and also ease-of-implementation for visualising evaluation (these may well be different problems which need different solutions). This is not discussed here at all.

Discussion

<If there's a GitHub Discussions topic or a GitHub Issue where this feature has been/is being discussed, link it here.>

Future work

  • Efficient tree diffs: see "Not in spec"
  • A decent "1.0" version. This needs thought as to what is useful to know on the frontend.
@brprice brprice added enhancement New feature or request triage This issue needs triage labels Oct 18, 2021
@brprice brprice self-assigned this Oct 18, 2021
@dhess dhess removed the triage This issue needs triage label Oct 18, 2021
@dhess
Copy link
Member

dhess commented Oct 18, 2021

Thanks, this looks good.

IMO, you can just move the "decent 1.0" comment to "Future work," as it will probably take us several iterations to get there, and we need not do them all under this one Feature Request. (If so, you may also want to re-title this issue, "Initial API for getTree" or similar.)

@brprice brprice changed the title Api for "getTree" Initial api for "getTree" Oct 19, 2021
@brprice brprice linked a pull request Oct 20, 2021 that will close this issue
@dhess dhess assigned dhess and unassigned brprice Oct 21, 2021
@ghost ghost closed this as completed in #180 Nov 16, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants