import LIB/default-instruction-set.lm;
import LIB/default-primitives.lm;
import LIB/default-rules.lm;
import LIB/default-stdlib.lm;
import LIB/default-templates.lm;
type XY X | (Y( U64 ));
type XYZ (Z( XY , U64 ));
f := λ(: x U64)(: y U64). (: (tail(
(let buffer 555_u64)
(print 'F1_s)
(let xyz (Z( (Y( x )) y )))
(print (.0 xyz))
(print (.1 (as xyz Z)))
(let xy (.2 (as xyz Z)))
(print (.0 xy))
(print (.1(as xy Y)))
(print '\n_s)
xyz
)) XYZ);
f2 := λ(: x U64). (: (tail(
(let buffer 555_u64)
(print 'F2_s)
(let xyz (Z( (Y( x )) 456_u64 )))
(print (.0 xyz))
(print (.1 (as xyz Z)))
(let xy (.2 (as xyz Z)))
(print (.0 xy))
(print (.1(as xy Y)))
(print '\n_s)
xyz
)) XYZ);
f3 := λ(: x U64)(: y U64). (: (tail(
(let buffer 555_u64)
(print 'F3_s)
(let xyz (Y( x )))
(print (.0 xyz))
(print (.1 (as xyz Y)))
(print '\n_s)
xyz
)) XY);
f4 := λ(: x U64). (: (tail(
(let buffer 555_u64)
(print 'F4_s)
(let xyz (Y( x )))
(print (.0 xyz))
(print (.1 (as xyz Y)))
(print '\n_s)
xyz
)) XY);
main := λ. (: (tail(
(let xyz (f( 123_u64 456_u64 )))
(print (.0 xyz))
(print (.1 (as xyz Z)))
(let xy (.2 (as xyz Z)))
(print (.0 xy))
(print (.1(as xy Y)))
(print '\n_s)
(match (f( 123_u64 456_u64 )) (
()
( (Z( (Y( x )) y )) (tail(
(print x)
(print y)
(print '\n_s)
)))
))
(let xyz (f3( 123_u64 456_u64 )))
(print (.0 xyz))
(print (.1 (as xyz Y)))
(match (f3( 123_u64 456_u64 )) (
()
( (Y( x )) (tail(
(print x)
(print '\n_s)
)))
))
(let xyz (f4( 123_u64 )))
(print (.0 xyz))
(print (.1 (as xyz Y)))
(match (f4( 123_u64 )) (
()
( (Y( x )) (tail(
(print x)
(print '\n_s)
)))
))
(let xyz (f2( 123_u64 )))
(print (.0 xyz))
(print (.1 (as xyz Z)))
(let xy (.2 (as xyz Z)))
(print (.0 xy))
(print (.1(as xy Y)))
(print '\n_s)
(match (f2( 123_u64 )) (
()
( (Z( (Y( x )) y )) (tail(
(print x)
(print y)
(print '\n_s)
)))
))
)) Nil);