raz / conform / run / MatchQualified.raz

41 lines · 925 B · raw · history · last change 16ccda37

1(* An arm names its case as it is written anywhere else: alone, with
2 its type, with its module, or with both (report section 7.4). *)
3module MatchQualified;
4import Out, EnumKinds, Shared;
5
6type Kind = (start, done);
7
8proc kind(k: Kind);
9begin
10 match k of
11 | Kind.start: Out.str("start ");
12 | done: Out.str("done ");
13 end;
14end;
15
16proc elem(e: EnumKinds.Elem);
17begin
18 match e of
19 | EnumKinds.Elem.para: Out.str("para ");
20 | EnumKinds.rule: Out.str("rule ");
21 | bold: Out.str("bold ");
22 end;
23end;
24
25proc shape(s: Shared.Shape);
26begin
27 match s of
28 | Shared.dot: Out.str("dot ");
29 | Shared.circle(r): Out.int(r); Out.str(" ");
30 end;
31end;
32
33proc main*;
34begin
35 kind(start); kind(done);
36 elem(EnumKinds.Elem.para); elem(EnumKinds.Elem.bold); elem(EnumKinds.rule);
37 shape(Shared.dot); shape(Shared.circle(3));
38 Out.ln;
39end;
40
41end MatchQualified.