main shrub/kav / examples / color.kav
 1datatype Color {
 2    | Red
 3    | Green
 4    | Blue
 5}
 6
 7
 8fn next(c: Color) -> Color {
 9    case c of {
10    | Red   => Green
11    | Green => Blue
12    | Blue  => Red
13    }
14}
15
16fn col2int(c: Color) -> int {
17    case c of {
18    | Red   => 1
19    | Green => 2
20    | Blue  => 3
21    }
22}
23
24pub fn main() -> int {
25    val c = next(Red)
26    val d = next(c)
27    col2int(c) + col2int(d)
28}