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

Reflect "explicit binders for type variables" feature in Types? #11319

Closed
pitag-ha opened this issue Jun 14, 2022 · 2 comments
Closed

Reflect "explicit binders for type variables" feature in Types? #11319

pitag-ha opened this issue Jun 14, 2022 · 2 comments

Comments

@pitag-ha
Copy link
Member

Has there been a follow-up somewhere on @gasche's question whether a cd_vars field should be added to Types.constructor_declaration?

The reason for that question is the following: when explicit binders for type variables were introduced for 4.14, the cd_vars field was added both to Typedtree.constructor_declaration and to Parsetree.constructor_declaration. It wasn't added to Types.constructor_declaration though. From a theoretical point of view, doing so might be good for coherency. And from a practical point of view, doing so would have the advantage that PPXs that rely on the Types module, could treat the new feature (see for exampleppx_import and the conversation about that here).

Of course, this question isn't the most urgent thing right now, so feel free to answer once the 5.0 alpha release work has calmed down.

@pitag-ha pitag-ha changed the title Add a cd_vars field to Types.constructor_declaration? Reflect "explicit binders for type variables" feature in Types? Jun 14, 2022
@lpw25
Copy link
Contributor

lpw25 commented Jun 15, 2022

I would generally say that cd_vars should not appear in Types.constructor_declaration. The stuff in Types is supposed to represent that semantic type, and doesn't generally contain additional data about the exact syntax that was used. Obviously we remember some syntactic information to improve error messages, but mostly we throw that stuff away.

I think that ppx_import shouldn't really need cd_vars to produce valid syntax. It should be possible both to add explicit binders for all bound type variables or to produce no explicit binders, and either would seem to be fine for its use case.

@pitag-ha
Copy link
Member Author

Thanks a lot for the nice and quick answer @lpw25! I'm convinced now that the explicit binders shouldn't be reflected in Types (I wasn't aware they don't have any impact on the semantics at all, and not even on the error messages).

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

No branches or pull requests

2 participants