plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
examples/match.plum
enum Color =
| Red
| Green
| Blue
enum Option =
| Some[Int]
| None
fun describeNumber(n: Int) -> Str =
match n
0 =>
"zero"
1 =>
"one"
_ =>
"many"
fun describeBool(b: Bool) -> Int =
match b
True =>
1
False =>
0
fun bindExample(n: Int) -> Int =
match n
x =>
x
fun describeColor(c: Color) -> Str =
match c
Red =>
"red"
Green =>
"green"
Blue =>
"blue"
fun describeOption(opt: Option) -> Int =
match opt
Some(v) =>
v
None =>
0
fun main() -> Int =
describeOption(Some(5))