fn(type$0, env$1, seen$2) =>
match $0 {
#reference(reference$10) =>
match @core.list-contains-string(list: $2, target: $10.part_hash, index: 0) {
true =>
$0,
false =>
match @core.part-type-lookup(env: $1.parts, part_hash: @core.string-concat(left: $10.part_hash, right: "#definition")) {
#ok(definition$11) =>
match $11 {
#reference(next$13) =>
@core.type-resolve-from(type: $11, env: $1, seen: @core.list-append(list: $2, item: $10.part_hash)),
#apply(next_apply$17) =>
@core.type-resolve-from(type: $11, env: $1, seen: @core.list-append(list: $2, item: $10.part_hash)),
_ =>
$11
},
#error(not_found$12) =>
$0
}
},
#apply(apply_type$14) =>
match @core.list-contains-string(list: $2, target: $14.part_hash, index: 0) {
true =>
$0,
false =>
match @core.part-type-lookup(env: $1.parts, part_hash: @core.string-concat(left: $14.part_hash, right: "#definition")) {
#ok(definition$15) =>
let substituted$16 = @core.type-substitute(type: $15, arguments: $14.arguments);
match $16 {
#reference(_) =>
@core.type-resolve-from(type: $16, env: $1, seen: @core.list-append(list: $2, item: $14.part_hash)),
#apply(_) =>
@core.type-resolve-from(type: $16, env: $1, seen: @core.list-append(list: $2, item: $14.part_hash)),
_ =>
$16
},
_ =>
$0
}
},
_ =>
$0
}