Skip to content

Conversation

cristianoc
Copy link
Collaborator

Summary

  • detect real invocations during type checking and annotate the typed tree
  • lower those annotations directly to the existing lambda primitives instead of relying on the Parsetree PPX
  • drop the Parsetree transformer, update docs/tests, and adjust runtime examples to match the new API surface

Testing

  • make test (docstring generator still fails on pre-existing Stdlib_DataView snippets)

return category.name;
let __res_option_opt;
if (incidentId !== undefined) {
let incidentId$1 = Primitive_option.valFromOption(incidentId);
Copy link
Member

Choose a reason for hiding this comment

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

Output looks worse than the Parsetree version.
These Primitive_option.valFromOption should not be needed.

function testPrimitive() {
console.log(42);
let value = 42;
console.log(value);
Copy link
Member

Choose a reason for hiding this comment

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

Why did we lose the optimization here?

@cknitt
Copy link
Member

cknitt commented Sep 23, 2025

As we are doing the transformation on the typed level now, shouldn't we add some type checking tests, too?

```rescript
Js.String.charCodeAt(0, `😺`) == 0xd83d->Belt.Int.toFloat
Js.String.codePointAt(0, `😺`) == Some(0x1f63a)
Copy link
Member

Choose a reason for hiding this comment

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

Are you removing this because it's not really an example for charCodeAt or because the test failed? (Actually this should be correct / the test should work.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't know it failed before already. Not sure.

Copy link
Member

Choose a reason for hiding this comment

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

You may need to remove tests/docstring_tests/generated_mocha_test.res and re-run the tests.

@cristianoc cristianoc force-pushed the option-stdlib-typed-opt branch from 9202879 to fd1a69d Compare September 23, 2025 14:22
let category = categoryId !== undefined ? Belt_MapString.get(categories, categoryId) : undefined;
if (category !== undefined) {
return category.name;
let __res_option_opt = incidentId !== undefined ? Belt_MapString.get(incidents, incidentId) : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Now the output is the same except for worse variable naming. 🙂
Can we produce the identical output?

@cknitt cknitt force-pushed the option-stdlib-typed-opt branch from 97812a7 to 5ac5fc9 Compare September 24, 2025 15:56
@cknitt cknitt force-pushed the option-stdlib-typed-opt branch from 5ac5fc9 to 5171806 Compare September 24, 2025 16:01
@cknitt
Copy link
Member

cknitt commented Sep 24, 2025

Rebased after the Docstring test fixes

@cknitt cknitt marked this pull request as draft September 25, 2025 14:14
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