type-of-s-with-fields := λ(: base-type Type)(: tag String)(: compound AST)(: field-index U64). (: ( (let r TAny) (match compound ( () ( (Lit( tt _ )) ( (let nt TAny) (match (parse-field-of tt) ( () ( (Tuple( '_s ft )) (set nt ft) ) ( (Tuple( fn ft )) ( (add-alias( (clone-rope(SCons( (close(SAtom '._s)) (close(SAtom fn)) ))) (clone-rope(SCons( (close(SAtom '._s)) (close(SAtom(to-string field-index))) ))) (t3( 'Arrow_s (and( (t1 tag) base-type )) ft )) )) (print 'Mark\sField\s_s)(print fn)(print '\s:\s_s)(print ft)(print '\n_s) (set nt ft) )) )) (set r nt) )) ( (Var( tt _ )) ( (let nt TAny) (match (parse-field-of tt) ( () ( (Tuple( '_s ft )) (set nt ft) ) ( (Tuple( fn ft )) ( (add-alias( (clone-rope(SCons( (close(SAtom '._s)) (close(SAtom fn)) ))) (clone-rope(SCons( (close(SAtom '._s)) (close(SAtom(to-string field-index))) ))) (t3( 'Arrow_s (and( (t1 tag) base-type )) ft )) )) (set nt ft) )) )) (set r nt) )) ( (App( (App( lt (Lit( ',_s _ )) )) rt )) ( (let ltt (type-of-s-with-fields( base-type tag lt (+( field-index 1_u64 )) ))) (let rtt (type-of-s-with-fields( base-type tag rt field-index ))) (set r (t3( 'Cons_s ltt rtt ))) )) ( _ (exit-error( 'Malformed\sType\sDefinition_s compound ))) )) r ) Type);