aboutsummaryrefslogtreecommitdiff
path: root/src/lib/util.rs
blob: 51f0707c6be9ef04bfecf0cd90c823cf29add6af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
type option[T] = tag(none(), some(T));

type operator[T, U] = fn(&T) -> U;

fn option_map[T, U](&operator[T, U] f, &option[T] opt) -> option[U] {
  alt (opt) {
    case (some[T](x)) {
      ret some[U](f(x));
    }
    case (none[T]()) {
      ret none[U]();
    }
  }
}

fn id[T](T x) -> T {
  ret x;
}

type rational = rec(int num, int den);