2.12. Numbered unions

Numbered unions are algebraic types used to represent alternative cases. The infix operator + is the type combinator used to denote them. The number is zero origin.
Start felix section to tut/tutorial/tut-1.12-0.flx[1 /1 ]
     1: #line 660 "./lpsrc/flx_tutorial.pak"
     2: #import <flx.flxh>
     3: open Long;
     4: 
     5: typedef three = unit +  unit + unit;
     6: typedef four = 4;
     7: typedef nu = int + double + long;
     8: 
     9: 
    10: val x1 = case 0 of (1+1+1);
    11: val x2 = case 1 of 3;
    12: 
    13: proc g(x:three) {
    14:   print "Case ";
    15:   match x with
    16:   | case 0 => { print 0; }
    17:   | case 1 => { print 1; }
    18:   | case 2 => { print 2; }
    19:   endmatch;
    20:   print " of three\n";
    21: }
    22: 
    23: g x1;
    24: g x2;
    25: g (case 2 of three);
    26: 
    27: proc f(x:nu) {
    28:   match x with
    29:   | case 0 ?z => { print "case 0 "; print z; }
    30:   | case 1 ?z => { print "case 1 "; print z; }
    31:   | case 2 ?z => { print "case 2 "; print z; }
    32:   endmatch;
    33:   print "\n";
    34: }
    35: 
    36: val i1 = (case 0 of nu) 33;
    37: val i2 = (case 1 of nu) 3.3;
    38: val i3 = (case 2 of nu) 33L;
    39: f i1;
    40: f i2;
    41: f i3;
End felix section to tut/tutorial/tut-1.12-0.flx[1]
Start data section to tut/tutorial/tut-1.12-0.expect[1 /1 ]
     1: Case 0 of three
     2: Case 1 of three
     3: Case 2 of three
     4: case 0 33
     5: case 1 3.3
     6: case 2 33
End data section to tut/tutorial/tut-1.12-0.expect[1]