-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5298 from sellout/empty-match
Support pattern matching on empty types
- Loading branch information
Showing
12 changed files
with
164 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
```unison | ||
structural type Void = | ||
``` | ||
|
||
```ucm | ||
scratch/main> add | ||
``` | ||
|
||
We should be able to `match` on empty types like `Void`. | ||
|
||
```unison | ||
Void.absurdly : '{e} Void ->{e} a | ||
Void.absurdly v = match !v with | ||
``` | ||
|
||
```unison | ||
Void.absurdly : Void -> a | ||
Void.absurdly v = match v with | ||
``` | ||
|
||
And empty `cases` should also work. | ||
|
||
```unison | ||
Void.absurdly : Void -> a | ||
Void.absurdly = cases | ||
``` | ||
|
||
But empty function bodies are not allowed. | ||
|
||
```unison:error | ||
Void.absurd : Void -> a | ||
Void.absurd x = | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
``` unison | ||
structural type Void = | ||
``` | ||
|
||
``` ucm | ||
Loading changes detected in scratch.u. | ||
I found and typechecked these definitions in scratch.u. If you | ||
do an `add` or `update`, here's how your codebase would | ||
change: | ||
⍟ These new definitions are ok to `add`: | ||
structural type Void | ||
``` | ||
``` ucm | ||
scratch/main> add | ||
⍟ I've added these definitions: | ||
structural type Void | ||
``` | ||
We should be able to `match` on empty types like `Void`. | ||
|
||
``` unison | ||
Void.absurdly : '{e} Void ->{e} a | ||
Void.absurdly v = match !v with | ||
``` | ||
|
||
``` ucm | ||
Loading changes detected in scratch.u. | ||
I found and typechecked these definitions in scratch.u. If you | ||
do an `add` or `update`, here's how your codebase would | ||
change: | ||
⍟ These new definitions are ok to `add`: | ||
Void.absurdly : '{e} Void ->{e} a | ||
``` | ||
``` unison | ||
Void.absurdly : Void -> a | ||
Void.absurdly v = match v with | ||
``` | ||
|
||
``` ucm | ||
Loading changes detected in scratch.u. | ||
I found and typechecked these definitions in scratch.u. If you | ||
do an `add` or `update`, here's how your codebase would | ||
change: | ||
⍟ These new definitions are ok to `add`: | ||
Void.absurdly : Void -> a | ||
``` | ||
And empty `cases` should also work. | ||
|
||
``` unison | ||
Void.absurdly : Void -> a | ||
Void.absurdly = cases | ||
``` | ||
|
||
``` ucm | ||
Loading changes detected in scratch.u. | ||
I found and typechecked these definitions in scratch.u. If you | ||
do an `add` or `update`, here's how your codebase would | ||
change: | ||
⍟ These new definitions are ok to `add`: | ||
Void.absurdly : Void -> a | ||
``` | ||
But empty function bodies are not allowed. | ||
|
||
``` unison | ||
Void.absurd : Void -> a | ||
Void.absurd x = | ||
``` | ||
|
||
``` ucm | ||
Loading changes detected in scratch.u. | ||
I expected a block after this (in red), but there wasn't one. Maybe check your indentation: | ||
2 | Void.absurd x = | ||
``` |
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