tag-to-fields-index := (: BTreeEqEOF BTreeEq>); index-fields-of-tag := λ(: tag String)(: fields-params Type)(: fields-rhs Type). (: ( (.bind( (as (& tag-to-fields-index) BTreeEq>[]) tag (Tuple( fields-params fields-rhs )) )) ) Nil); fields-of-tag := λ(: tag String). (: ( (let r (.lookup( tag-to-fields-index tag (Tuple( TAny TAny )) ))) r ) Tuple); fields-of-tag := λ(: tag Type)(: class Type). (: ( (let rhst TAny) (match tag ( () ( (TGround( 'Tag_s (LCons( (TGround( ts _ )) LEOF )) )) (match (fields-of-tag ts) ( () ( (Tuple( TAny TAny )) () ) ( (Tuple( fields-lhs fields-rhs )) ( (set rhst (substitute( (unify( fields-lhs class )) fields-rhs ))) )) ))) ( _ ( (print 'Invalid\sTag\sIn\sfields-of-tag\s_s) (print tag)(print '\n_s) (exit 1_u64) )) )) (set rhst (with-size rhst)) (let rt (TGround( 'Fields_s (close(cons( (fields-of-type( (t3( 'Cons_s rhst (TAnd( (close(t1 'U64_s)) (close(t2( 'Sized_s (t1 '8_s) ))) )) )) )) (: LEOF List) )))))) rt ) Type);