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

Add REPL option to apply Core transformations #1796

Merged
merged 1 commit into from
Feb 1, 2023
Merged

Conversation

paulcadman
Copy link
Collaborator

Core transformations apply to the whole InfoTable, the REPL needs to apply Core transformations to the single node that it compiles from the user input string.

The solution in this commit is to:

  1. Compile the input string as before to obtain a Core Node.
  2. Add this Node to a copy of the Core InfoTable for the loaded file.
  3. Apply the (CLI specified) Core transformations to this InfoTable.
  4. Extract the (now transformed) Node from the InfoTable.

We can think of a way to improve this, maybe when we tackle allowing the user to make new definitions in the REPL.

As soon as compilation of pattern matching is complete we should enable some (all?) Core transformations by default.

Example:

At the moment we get the following result in the REPL:

juvix repl
...
Stdlib.Prelude> 1 + 1
suc (suc zero)

After this commit we can turn on nat-to-int transformation:

juvix repl -t nat-to-int
Stdlib.Prelude> 1 + 1
2

Core transformations apply to the whole InfoTable, the REPL needs to
apply Core transformations to the single node that it compiles from the
user input string.

The solution in this commit is to:

1. Compile the input string as before to obtain a Core Node.
2. Add this Node to a copy of the Core InfoTable for the loaded file.
3. Apply the (CLI specified) Core transformations to this InfoTable.
4. Extract the (now transformed) Node from the InfoTable.

We can think of a way to improve this, maybe when we tackle allowing the
user to make new definitions in the REPL.

As soon as compilation of pattern matching is complete we should enable
some (all?) Core transformations by default.

Example:

At the moment we get the following result in the repl:

```
juvix repl
...
Stdlib.Prelude> 1 + 1
suc (suc zero)
```

After this commit we can turn on `nat-to-int` transformation:

```
juvix repl -t nat-to-int
Stdlib.Prelude> 1 + 1
2
```
@paulcadman paulcadman added enhancement New feature or request core Related to JuvixCore repl labels Feb 1, 2023
@paulcadman paulcadman added this to the 0.3 - Valencia milestone Feb 1, 2023
@paulcadman paulcadman self-assigned this Feb 1, 2023
@paulcadman paulcadman merged commit 672e400 into main Feb 1, 2023
@paulcadman paulcadman deleted the repl-transform-opt branch February 1, 2023 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to JuvixCore enhancement New feature or request repl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants