1: #line 374 "./lpsrc/flx_regress.pak"
2:
3:
4:
5:
6:
7: fun appl(x:int, f:int * int -> int):int = {
8: return f (x,x);
9: }
10:
11: print "closure of add primitive ";
12: print (appl (2, add of (int*int))); endl;
13:
14:
15: struct X { x:int; }
16: fun execX(p:int->X):X = { return p(1); }
17: proc xprint(x:X){ print "struct X"; }
18: xprint (execX (X of (int))); endl;
19: xprint (execX (X)); endl;
20:
21:
22: fun execx(p:X->int,a:X):int => p a;
23: proc pprint(x:int){ print "struct X: x get projection "; print x; }
24:
25:
26: fun getx(a:X):int=>a.x;
27: pprint (execx (getx of (X), X(42))); endl;
28:
29:
30: header """
31: struct CX {int x; };
32: """;
33:
34: cstruct CX { x:int; }
35: fun execCX(p:int->CX):CX = { return p(1); }
36: proc xprint(x:CX){ print "struct CX"; }
37: xprint (execCX (CX of (int))); endl;
38: xprint (execCX (CX)); endl;
39:
40:
41:
42: typedef Y = 1 + int;
43: fun exec2(y2:int->Y,a:int):Y= { return y2 a; }
44: proc yprint(y:Y) { print "union Y"; }
45: yprint (exec2(case 1 of Y, 1)); endl;
46:
47:
48: union U = | A | B of int;
49: fun exec3(y2:int->U,a:int):U= { return y2 a; }
50: proc xprint(y:U) { print "union U"; }
51: xprint (exec3(B of (int), 1)); endl;