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

Refactor: separate out linting from compilation #338

Open
kubukoz opened this issue Sep 25, 2023 · 0 comments
Open

Refactor: separate out linting from compilation #338

kubukoz opened this issue Sep 25, 2023 · 0 comments

Comments

@kubukoz
Copy link
Owner

kubukoz commented Sep 25, 2023

Playground has some linting abilities (diagnostics on WARN level), such as unused imports and deprecated features. Historically, these have been implemented as part of the QueryCompilerVisitor, which traverses the input type schema and returns roughly an AST => Ior[Diagnostics, Decoded].

This has several problems:

Coupling

Self-explanatory: the linting abilities are coupled to compilation, and adding more will pollute the compiler code, which is arguably the most important piece of the whole project.

Ior composition

This one is more subtle: non-successful Iors never compose RHS with successful ones. This requires extra care in things like parTraverses, as well as |+| and similar.

Additionally, we have seal, which turns any ERROR diagnostics in an Ior into a failed Ior.

Ior is used so that we can produce non-fatal diagnostics together with a successful result, and splitting up the compiler into two separate components would remove the need for it. In addition, seal would be redundant because every compiler diagnostic would be an error.


Given the reasons above, it's at least worth an experiment: extract a linting visitor and remove the remaining linting abilities from the compiler.

The effects of the visitors should look a little like:

  • compiler: AST => Either[Nel[Diagnostic], A]
  • linter: AST => List[Diagnostic]
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

1 participant