main shrub/kav / examples / goal.kav
 1//line comment
 2/* block comment */
 3
 4newtype id = int
 5
 6sortdef nat = [n: int | n >= 0]
 7
 8typedef List1[a: type, n: type] = List[a, n + 1]
 9
10pub linear datatype List[a: type, n: nat] {
11    | Nil : List[a, 0]
12    | [m: nat] Cons(a, List[a, m]) : List[a, m+1]
13}
14
15pub struct Point {
16    x: int,
17    y: int
18}
19
20fn factorial(n: int) -> int {
21    if n <= 1 then 1
22    else n * factorial(n - 1)
23}
24
25fn howbigisx(x: int) -> int {
26    guard {
27    | x == 0 => 0
28    | x < 5  => 5
29    | _      => 100
30    }
31}
32
33pub fn main() -> int  {
34    val a = factorial(5)
35    val b: int = howbigisx(3)
36    a + b /* returns int */
37}