aboutsummaryrefslogtreecommitdiff
path: root/examples/res.ek
blob: f7c96dfff0be32a244a4b70de6275d44af7cb6c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* simple example with C-like strings. A real implementation would likely want
 * to use a string wrapper or something. */

typedef i27 {}
typedef i9 {}

typedef res[any T] {
	*i9 e;
	T v;

	ok(T v => res![T]) {
		return res![T]{.e = 0 as *i9, .v = v};
	}

	error(*i9 e, T v => res![T]) {
		return res![T]{.e = e, .v = v};
	}
}

define any[] {}

main()
{
	const a = ok::res![i27](20);
}