plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
examples/types.plum
| 0e1801a | 1 | type Point = |
| 0e1801a | 2 | x: Int |
| 0e1801a | 3 | y: Int |
| 0e1801a | 4 | |
| 0e1801a | 5 | type Named(Stringable) = |
| 0e1801a | 6 | name: Str |
| 0e1801a | 7 | |
| 0bb6882 | 8 | type Box[T] = |
| 0bb6882 | 9 | value: T |
| 0e1801a | 10 | |
| 0e1801a | 11 | trait Shape = |
| 0e1801a | 12 | area() -> Float |
| 0e1801a | 13 | perimeter() -> Float |
| 0e1801a | 14 | |
| 0bb6882 | 15 | trait Comparable[T: Ord] = |
| 0bb6882 | 16 | compareTo(other: T) -> Int |
| 0e1801a | 17 | |
| 0e1801a | 18 | enum Color = |
| 0e1801a | 19 | | Red |
| 0e1801a | 20 | | Green |
| 0e1801a | 21 | | Blue |
| 0e1801a | 22 | |
| 0e1801a | 23 | enum Option = |
| 0bb6882 | 24 | | Some[Int] |
| 0e1801a | 25 | | None |
| 2e28ecc | 26 | |
| 0fe3528 | 27 | fun makeIntBox() -> Box = |
| 2e28ecc | 28 | Box(value: 5) |
| 2e28ecc | 29 | |
| 0fe3528 | 30 | fun makeStrBox() -> Box = |
| 2e28ecc | 31 | Box(value: "x") |