def encode_type(primary_type, types):
<EOL>deps = get_dependencies(primary_type, types)<EOL>sorted_deps = (primary_type,) + tuple(sorted(deps))<EOL>result = '<STR_LIT>'.join(<EOL>[<EOL>encode_struct(struct_name, types[struct_name])<EOL>for struct_name in sorted_deps<EOL>]<EOL>)<EOL>return result<EOL>
The type of a struct is encoded as name ‖ "(" ‖ member₁ ‖ "," ‖ member₂ ‖ "," ‖ … ‖ memberₙ ")"
where each member is written as type ‖ " " ‖ name.