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

Output typing map #345

Closed
1 of 2 tasks
Tracked by #2350
shonfeder opened this issue Nov 16, 2022 · 2 comments · Fixed by #370
Closed
1 of 2 tasks
Tracked by #2350

Output typing map #345

shonfeder opened this issue Nov 16, 2022 · 2 comments · Fixed by #370
Assignees

Comments

@shonfeder
Copy link
Contributor

shonfeder commented Nov 16, 2022

As per recent TNT decisions, we plan to communicate specs to Apalache via (at least) two files:

  1. A (module-flattened) AST of the spec
  2. A dump of the type map, which gives the types inferred for each term

Currently, afaict, we have no mechanism for obtaining (2), but we'll need that.

cc/ @bugarela, in case you have thoughts on this or I'm mistaken.

@shonfeder shonfeder self-assigned this Nov 16, 2022
@bugarela
Copy link
Collaborator

Makes sense to me! I'm also not oppose to combining these 2 files into one, by adding the type information to the correspondent AST nodes (in the file, not in the IR).

We do want to produce some human-readable dumps of the inferred types at some point. I believe the best solution for that would be to combine the pretty printed IR with the pretty printed correspondent types in some sort of annotation syntax (i.e. val x: bool = y: int > 1). That shouldn't interfere with what you will be doing for Apalache since that's focused on machine readability, but I think it's useful to keep this scenario in mind while making decisions.

@shonfeder
Copy link
Contributor Author

I'm also not oppose to combining these 2 files into one, by adding the type information to the correspondent AST nodes

I'm not sure if this would make sense unless we wanted to use that representation in our IR. Otherwise it requires a different representation of the AST just for the purposes of serialization (at minimum, we'll have to add a field for inferred types to each node.

I think we might just add an extra field to the JSON blob produced by typecheck that holds a dump of the type map?

shonfeder pushed a commit that referenced this issue Nov 21, 2022
Closes #215

This is introduced in a way to suggest turning to sweet-monads/either
for sequencing our error-prone computations.

The sequencing and composition of our top-level routines exposed by CLI
is currently done via imperative early exits. This makes it hard to
reason about the code in general, but also breaks our ability to compose
these routines. Looking towards #345, we'll need typecheck to receive
the output of parse, then add it's typing information, before finally
printing to the `--out` location. This requires composing the routines
while handling possible error states, and just bailing with exit codes
won't work for that. Since we are already using `Either`, and since it
is designed for facilitating the composition of error-prone code, I
think we can massage these routines into shape with a few well-placed
Either's. ;)
shonfeder pushed a commit that referenced this issue Nov 22, 2022
Closes #215

This is introduced in a way to suggest turning to sweet-monads/either
for sequencing our error-prone computations.

The sequencing and composition of our top-level routines exposed by CLI
is currently done via imperative early exits. This makes it hard to
reason about the code in general, but also breaks our ability to compose
these routines. Looking towards #345, we'll need typecheck to receive
the output of parse, then add it's typing information, before finally
printing to the `--out` location. This requires composing the routines
while handling possible error states, and just bailing with exit codes
won't work for that. Since we are already using `Either`, and since it
is designed for facilitating the composition of error-prone code, I
think we can massage these routines into shape with a few well-placed
Either's. ;)
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 a pull request may close this issue.

2 participants