This commit is contained in:
ProgramSnail 2023-03-31 12:10:12 +03:00
parent 582ad5668e
commit 0d62ae0814
29 changed files with 99479 additions and 1166 deletions

22
tests/variants.lang Normal file
View file

@ -0,0 +1,22 @@
decl test_variants : Unit -> Unit
def test_variants = {
var variant1 = | 'a' | 2 | "hello"
var | val | err = f x // optional types for each
; val -> "something" // open variant as value in expr
; val -!> "nothing" // open variant as None in expr
; ?err // open variant as value, or return None (if possible), operator
match variant1 with
| 'a' -> "something"
| 2 -> "something"
| "hello" -> "something"
| a -> "Something"
| String.of str -> "something"
| Int.of i -> "someting"
| 11 -> "nothing"
}
// ???????????????????????