-
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 #1642. This pr introduces syntax for convenient record updates. Example: ``` type Triple (A B C : Type) := | mkTriple { fst : A; snd : B; thd : C; }; main : Triple Nat Nat Nat; main := let p : Triple Nat Nat Nat := mkTriple 2 2 2; p' : Triple Nat Nat Nat := p @triple{ fst := fst + 1; snd := snd * 3 }; f : Triple Nat Nat Nat -> Triple Nat Nat Nat := (@triple{fst := fst * 10}); in f p'; ``` We write `@InductiveType{..}` to update the contents of a record. The `@` is used for parsing. The `InductiveType` symbol indicates the type of the record update. Inside the braces we have a list of `fieldName := newValue` items separated by semicolon. The `fieldName` is bound in `newValue` with the old value of the field. Thus, we can write something like `p @triple{fst := fst + 1;}`. Record updates `X@{..}` are parsed as postfix operators with higher priority than application, so `f x y @x{q := 1}` is equivalent to `f x (y @x{q := 1})`. It is possible the use a record update with no argument by wrapping the update in parentheses. See `f` in the above example.
- Loading branch information
1 parent
18b664a
commit f7382ca
Showing
26 changed files
with
619 additions
and
70 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
Oops, something went wrong.