equal
deleted
inserted
replaced
196 end; |
196 end; |
197 |
197 |
198 fun massage_indirect_corec_call ctxt has_call massage_direct_call bound_Ts res_U t = |
198 fun massage_indirect_corec_call ctxt has_call massage_direct_call bound_Ts res_U t = |
199 let |
199 let |
200 val typof = curry fastype_of1 bound_Ts; |
200 val typof = curry fastype_of1 bound_Ts; |
201 val build_map_Inl = build_map ctxt (uncurry Inl_const o dest_sumT o fst); |
201 val build_map_Inl = build_map ctxt (uncurry Inl_const o dest_sumT o snd) |
202 |
202 |
203 fun check_and_massage_direct_call U T t = |
203 fun check_and_massage_direct_call U T t = |
204 if has_call t then factor_out_types ctxt massage_direct_call dest_sumT U T t |
204 if has_call t then factor_out_types ctxt massage_direct_call dest_sumT U T t |
205 else build_map_Inl (U, T) $ t; |
205 else build_map_Inl (T, U) $ t; |
206 |
206 |
207 fun check_and_massage_unapplied_direct_call U T t = |
207 fun check_and_massage_unapplied_direct_call U T t = |
208 let val var = Var ((Name.uu, Term.maxidx_of_term t + 1), domain_type (typof t)) in |
208 let val var = Var ((Name.uu, Term.maxidx_of_term t + 1), domain_type (typof t)) in |
209 Term.lambda var (check_and_massage_direct_call U T (t $ var)) |
209 Term.lambda var (check_and_massage_direct_call U T (t $ var)) |
210 end; |
210 end; |
239 list_comb (f', map3 massage_call (binder_types (typof f')) (map typof args) args) |
239 list_comb (f', map3 massage_call (binder_types (typof f')) (map typof args) args) |
240 end |
240 end |
241 | NONE => |
241 | NONE => |
242 (case t of |
242 (case t of |
243 t1 $ t2 => |
243 t1 $ t2 => |
244 if has_call t2 then |
244 (if has_call t2 then |
245 check_and_massage_direct_call U T t |
245 check_and_massage_direct_call U T t |
246 else |
246 else |
247 massage_map U T t1 $ t2 |
247 massage_map U T t1 $ t2 |
248 handle AINT_NO_MAP _ => check_and_massage_direct_call U T t |
248 handle AINT_NO_MAP _ => check_and_massage_direct_call U T t) |
249 | _ => check_and_massage_direct_call U T t)) |
249 | _ => check_and_massage_direct_call U T t)) |
250 | _ => ill_formed_corec_call ctxt t)) |
250 | _ => ill_formed_corec_call ctxt t)) |
251 U T |
251 U T |
252 in |
252 in |
253 massage_call res_U (typof t) (Envir.beta_eta_contract t) |
253 massage_call res_U (typof t) (Envir.beta_eta_contract t) |