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

Adds Danger.parseFloat, System.sampleCount, Danger.now #2974

Merged
merged 5 commits into from Jan 17, 2024

Conversation

OAGr
Copy link
Contributor

@OAGr OAGr commented Jan 17, 2024

Adds 3 Std Lib functions. Also adds a Docs page for System

@OAGr OAGr requested a review from berekuk as a code owner January 17, 2024 03:37
Copy link

changeset-bot bot commented Jan 17, 2024

🦋 Changeset detected

Latest commit: db8f17b

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 17, 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 17, 2024 11:24pm
squiggle-components ✅ Ready (Inspect) Visit Preview Jan 17, 2024 11:24pm
squiggle-website ✅ Ready (Inspect) Visit Preview Jan 17, 2024 11:24pm
1 Ignored Deployment
Name Status Preview Updated (UTC)
quri-ui ⬜️ Ignored (Inspect) Visit Preview Jan 17, 2024 11:24pm

@@ -23,6 +23,10 @@ describe("Danger functions", () => {
testEvalToBe("Danger.allCombinations([3])", "[[3]]");
testEvalToBe("Danger.allCombinations([])", "[]");
});
describe("javascript", () => {
testEvalToBe("Danger.parseFloat('10.0') + 1", "11");
testEvalToBe("Danger.parseFloat('foo')", '"Parse Failed"');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't sure what the best error string was, because it's in Danger, we don't need to worry about quite as much.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the future, parseFloat("str").unwrap() could be good; for that, we'd need:

  1. some kind of GADTs or structs
  2. ideally, methods (because calling -> Result.unwrap is too verbose)
  3. exception handling

import { ImmutableMap } from "../utility/immutableMap.js";
import { Value, vString } from "../value/index.js";

// automatically updated on release by ops/ patch-js utils
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: I realized we'd need to change patch-js

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you just move it back to version.ts for now? I could update patch-js, but it's better if the patched file is small, because it will be reformatted on patch and Babel tends to ignore the whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, can do.

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.

Danger.parseFloat and System.sampleCount seem good to me, but I'm not happy about Date.now.

I probably shouldn't push back on it, because it's immediately useful, but it makes Squiggle runs less reproducible, and later it will interfere with caching and I predict we'll have to spend a lot of time untangling the consequences on this change.

The complexity of how to combine reproducible runs with mutable inputs is not trivial either way, and it's obvious we do want mutable inputs. So the question is whether we should think through the design now or later.

@@ -23,6 +23,10 @@ describe("Danger functions", () => {
testEvalToBe("Danger.allCombinations([3])", "[[3]]");
testEvalToBe("Danger.allCombinations([])", "[]");
});
describe("javascript", () => {
testEvalToBe("Danger.parseFloat('10.0') + 1", "11");
testEvalToBe("Danger.parseFloat('foo')", '"Parse Failed"');
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the future, parseFloat("str").unwrap() could be good; for that, we'd need:

  1. some kind of GADTs or structs
  2. ideally, methods (because calling -> Result.unwrap is too verbose)
  3. exception handling

import { ImmutableMap } from "../utility/immutableMap.js";
import { Value, vString } from "../value/index.js";

// automatically updated on release by ops/ patch-js utils
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you just move it back to version.ts for now? I could update patch-js, but it's better if the patched file is small, because it will be reformatted on patch and Babel tends to ignore the whitespace.

});

export const library = [
// It might make sense to later make this a constant, as this number shouldn't change at runtime.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but you can't just add it to stdlib, which is cached in SqProject.

I guess you could convert getStdLib() to getStdLib(env: Environment), and then invalidate it in SqProject on setEnvironment...

@OAGr OAGr merged commit 3c667ef into main Jan 17, 2024
6 checks passed
@OAGr OAGr deleted the parseFloat-sampleCount-Datenow branch January 17, 2024 23:27
@OAGr OAGr changed the title Adds Danger.parseFloat, System.sampleCount, Date.now Adds Danger.parseFloat, System.sampleCount, Danger.now Jan 17, 2024
@github-actions github-actions bot mentioned this pull request Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants