-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Closes #3328 This pr makes an important breaking change to the Juvix scoper. Previously, when defining a type, the constructors were put into the current scope. After this pr, they must be accessed through the type module that is generated. E.g. ``` type Unit := unit; -- BEFORE fun : Unit := unit; -- AFTER fun : Unit := Unit.unit; -- or open Unit using {unit} public; fun : Unit := unit; ``` Additionally, this pr adds the option `--migration` to the `juvix format` command. This option takes the identity of some migration we want to apply. For the purposes of migrating the existing codebase, I've added the `export-constructors` migration. When this option is given, the juvix formatter automatically adds an `open` statement after each type definition. E.g. Run `juvix format --migration export-constructors Example.juvix`. ``` module Example; type T := a | b; ``` Result: ``` module Example; type T := | a | b; open T using {a; b} public; ``` Using this method to migrate is not guaranteed to succeed, and manual adjustments might need to be made. 1. Forward references to constructors need to be qualified. E.g. ``` syntax operator :: cons; -- BEFORE syntax operator List.:: cons; -- AFTER type List (A : Type) := | nil | :: A (List A); ``` 3. Another thing to consider is that the migration should not be run twice on the same file, because then there will be repeated redundant `open` statements: ``` open List using {nil; ::} public; open List using {nil; ::} public; ``` I created a fish script for this: ``` #!/usr/bin/env fish cd ./tests for dir in (fd -a -t f "Package.juvix" | xargs -I{} dirname "{}") set witness "$dir/.migrated" if test -e $witness echo "Already processed: $dir" else echo "Processing $dir" if juvix format $dir --migration export-constructors --in-place touch $witness end end end ```
- Loading branch information
1 parent
410a052
commit 3bb9d8a
Showing
463 changed files
with
3,656 additions
and
2,355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ builtin bool | |
type Bool := | ||
| false | ||
| true; | ||
|
||
open Bool using {false; true} public; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ builtin maybe | |
type Maybe A := | ||
| nothing | ||
| just A; | ||
|
||
open Maybe using {nothing; just} public; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule juvix-stdlib
updated
49 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.