sizeof-type := λ(: tt Type). (: ( (let sz 0_u64) (match tt ( () ( TAny () ) ( (TVar _) () ) ( (TGround( class LEOF )) (set sz (size-of-class class)) ) ( (TGround( 'Sized_s (LCons( (TGround( szp LEOF )) LEOF )) )) ( (set sz (to-u64 szp)) )) ( (TGround( 'Array_s (LCons( TAny (LCons( p1 LEOF )) )) )) ( (set sz 8_u64) )) ( (TGround( 'Cons_s (LCons( p2 (LCons( p1 LEOF )) )) )) ( (set sz (+( (sizeof-aligned p1) (sizeof-aligned p2) ))) )) ( (TGround( 'Field_s (LCons( (TGround( szp LEOF )) (LCons( p1 LEOF )) )) )) ( (set sz (*( (sizeof-type p1) (to-u64 szp) ))) )) ( (TGround( tag _ )) ( (match (.lookup( type-complex-fields-index tag (Tuple( TAny TAny )) )) ( () ( (Tuple( TAny TAny )) () ) ( (Tuple( bt at )) ( (let ctx (unify( bt tt ))) (let arg-types (substitute( ctx at ))) (set sz (+( 8_u64 (sizeof-aligned arg-types) ))) )) )) )) ( (TAnd( lt rt )) ( (if (sizeof-type lt) ( (set sz (sizeof-type lt)) ) ( (set sz (sizeof-type rt)) )) )) ( _ ( (print 'Unexpected\sType\ssizeof-type\s_s) (print tt)(print '\n_s)(exit 1_u64) )) )) sz ) U64);