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

@location tag #3011

Merged
merged 10 commits into from
Jan 31, 2024
Merged

@location tag #3011

merged 10 commits into from
Jan 31, 2024

Conversation

OAGr
Copy link
Contributor

@OAGr OAGr commented Jan 28, 2024

One key consideration is if we can auto-add @location on decorators. If we can, then I think this should be named @location, as I don't expect it to be frequently used. If we can't, then I think we should name it @loc.

There's a significant issue with this PR, as I had to make a new ValueTagsWrapper class to handle some functions on ValueTags, due to an issue of circular dependencies. Curious if you have preffered ways of doing this. I also considered having BaseValue rely on an abstract class version of ValueTags, but that seemed like too much.

Tests are failing because the new toString format is different. If this PR is approved, I'll fix these.

* Forwardref-fix:
  Adds forwardRef to ViewerWithMenuBar and ViewerBody
@OAGr OAGr requested a review from berekuk as a code owner January 28, 2024 17:42
Copy link

changeset-bot bot commented Jan 28, 2024

🦋 Changeset detected

Latest commit: e1ee728

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

Copy link

vercel bot commented Jan 28, 2024

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

Name Status Preview Updated (UTC)
quri-hub ✅ Ready (Inspect) Visit Preview Jan 31, 2024 8:44pm
squiggle-components ✅ Ready (Inspect) Visit Preview Jan 31, 2024 8:44pm
squiggle-website ✅ Ready (Inspect) Visit Preview Jan 31, 2024 8:44pm
1 Ignored Deployment
Name Status Preview Updated (UTC)
quri-ui ⬜️ Ignored (Inspect) Visit Preview Jan 31, 2024 8:44pm

toString(): string {
return Object.entries(this.value)
.map(([key, value]) => `${key}: ${value?.toString()}`)
.join(", ");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also write this out. The previous setup would also work, though it's nice to organize it in ValueTagsWrapper, which can do a better job. (It can convert to Values, for use with the Library)

@OAGr
Copy link
Contributor Author

OAGr commented Jan 31, 2024

After this goes in, we should change exportData to also be a type.

Copy link
Collaborator

@berekuk berekuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this made me realize that ValueTagsWrapper (or tagUtils I proposed, whatever) could allow me to avoid circular dependency issues in #2978.

I'm also not sure how much sense ValueTags class makes now; we could convert everything to the functional style and pass ValueTagsType-shaped object everywhere, instead of having to organize things based on whether we have circular dependencies or not.

But it's not very important for now, feel free to merge.

}

// This class is meant for functions that depend on Value. BaseValue depends on ValueTags, so we can't call many functions there. Instead, we call them here.
export class ValueTagsWrapper {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could safely skip OOP here and use a module-as-plain-object:

export const tagUtils = {
  toVDict: (tags: ValueTags) => { ... },
  toValueMap: (tags: ValueTags) => { ... },
  toLocation: (tags: ValueTags) => { ... },
}

And then return tagUtils.toValueMap(tags).

(AFAICT the only function you need here is toValueMap, but exporting many small functions one by one can be annoying and less readable, so a top-level object is more convenient)

@berekuk
Copy link
Collaborator

berekuk commented Jan 31, 2024

After this goes in, we should change exportData to also be a type.

Later we might have to change it back to being a VDict, or a custom struct Value. I understand that using a type gives us type safety, though. Depends mostly on how soon we get custom structs, and how compile-time-safe they're going to be (will stdlib custom structs be shaped with TypeScript generics to map to TS object shapes? seems doable but difficult to predict).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants