plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
87b54a9
— Peter John
2026-07-20T13:33:14+05:30
docs+test: restore examples/match.plum to idiomatic bare-tail style; tail-position gap fixed
- README.md +0 -1
- examples/match.plum +11 -11
README.md
CHANGED
|
@@ -324,6 +324,5 @@ Some things parse and type-check but don't compile to wasm yet — `plum-wasm-co
|
|
|
324
324
|
- multi-subject `match` (`match a, b`)
|
|
325
325
|
- user-defined generics (they type-check but aren't monomorphized) — this also blocks `libs/std`'s actual `Option`/`Result`/`List`/`Map`, which are declared generically
|
|
326
326
|
- nested constructor patterns inside `match` (`Some(Some(v))`) — a constructor pattern's own sub-patterns must be a bare binding or `_`
|
|
327
|
-
- a function body's final statement being a `match`/`if` whose arms don't all use explicit `return` — the arm values are silently dropped instead of returned, producing invalid wasm rather than a clear error (workaround: always `return` from match/if arms in tail position)
|
|
328
327
|
|
|
329
328
|
`closure` (`|params| body`) exists in `grammar.js` but isn't wired into any reachable rule yet, so it doesn't actually parse in context.
|
examples/match.plum
CHANGED
|
@@ -10,39 +10,39 @@ enum Option =
|
|
|
10
10
|
describeNumber(n: Int) -> Str =
|
|
11
11
|
match n
|
|
12
12
|
0 =>
|
|
13
|
-
|
|
13
|
+
"zero"
|
|
14
14
|
1 =>
|
|
15
|
-
|
|
15
|
+
"one"
|
|
16
16
|
_ =>
|
|
17
|
-
|
|
17
|
+
"many"
|
|
18
18
|
|
|
19
19
|
describeBool(b: Bool) -> Int =
|
|
20
20
|
match b
|
|
21
21
|
True =>
|
|
22
|
-
|
|
22
|
+
1
|
|
23
23
|
False =>
|
|
24
|
-
|
|
24
|
+
0
|
|
25
25
|
|
|
26
26
|
bindExample(n: Int) -> Int =
|
|
27
27
|
match n
|
|
28
28
|
x =>
|
|
29
|
-
|
|
29
|
+
x
|
|
30
30
|
|
|
31
31
|
describeColor(c: Color) -> Str =
|
|
32
32
|
match c
|
|
33
33
|
Red =>
|
|
34
|
-
|
|
34
|
+
"red"
|
|
35
35
|
Green =>
|
|
36
|
-
|
|
36
|
+
"green"
|
|
37
37
|
Blue =>
|
|
38
|
-
|
|
38
|
+
"blue"
|
|
39
39
|
|
|
40
40
|
describeOption(opt: Option) -> Int =
|
|
41
41
|
match opt
|
|
42
42
|
Some(v) =>
|
|
43
|
-
|
|
43
|
+
v
|
|
44
44
|
None =>
|
|
45
|
-
|
|
45
|
+
0
|
|
46
46
|
|
|
47
47
|
main() -> Int =
|
|
48
48
|
describeOption(Some(5))
|