equal
deleted
inserted
replaced
193 fun force_iter is_rec i TU TU_rec raw_iters = |
193 fun force_iter is_rec i TU TU_rec raw_iters = |
194 let |
194 let |
195 val approx_fold = un_fold_of raw_iters |
195 val approx_fold = un_fold_of raw_iters |
196 |> force_typ names_lthy |
196 |> force_typ names_lthy |
197 (replicate (nth ns i) dummyT ---> (if is_rec then TU_rec else TU)); |
197 (replicate (nth ns i) dummyT ---> (if is_rec then TU_rec else TU)); |
198 val TUs = binder_fun_types (Term.typ_subst_atomic (Xs ~~ fpTs) (fastype_of approx_fold)); |
198 val subst = Term.typ_subst_atomic (Xs ~~ fpTs); |
199 val js = find_indices Type.could_unify |
199 val TUs = map_split dest_co_algT (binder_fun_types (fastype_of approx_fold)) |
200 TUs (map (Term.typ_subst_atomic (Xs ~~ fpTs)) fold_strTs); |
200 |>> map subst |
|
201 |> uncurry (map2 mk_co_algT); |
|
202 val js = find_indices Type.could_unify TUs |
|
203 (map2 (fn T => fn U => mk_co_algT (subst T) U) fold_preTs Xs); |
201 val Tpats = map (fn j => mk_co_algT (nth fold_pre_deads_only_Ts j) (nth Xs j)) js; |
204 val Tpats = map (fn j => mk_co_algT (nth fold_pre_deads_only_Ts j) (nth Xs j)) js; |
202 val iter = raw_iters |> (if is_rec then co_rec_of else un_fold_of); |
205 val iter = raw_iters |> (if is_rec then co_rec_of else un_fold_of); |
203 in |
206 in |
204 force_typ names_lthy (Tpats ---> TU) iter |
207 force_typ names_lthy (Tpats ---> TU) iter |
205 end; |
208 end; |