@@ -80,9 +80,16 @@ def $refresh_params(p*) =
8080 $refresh_list(param, $refresh_param, $subst_param, p*)
8181
8282
83+ def $refresh_typ(typ) : (typ, subst)
8384def $refresh_typbind(typbind) : (typbind, subst)
8485def $refresh_typbinds(typbind*) : (typbind*, subst)
8586
87+ def $refresh_typ(VAR x a*) = (VAR x a*, {})
88+ def $refresh_typ(optyp) = (optyp, {})
89+ def $refresh_typ(TUP tb*) = (TUP tb'*, s') -- if (tb'*, s') = $refresh_typbinds(tb*)
90+ def $refresh_typ(ITER t it) = (ITER t it, {})
91+ def $refresh_typ(MATCH x a* WITH inst*) = (MATCH x a* WITH inst*, {})
92+
8693def $refresh_typbind(x `: t) = (x' `: t, s)
8794 -- if (x', s) = $refresh_expid(x)
8895
@@ -125,25 +132,20 @@ def $subst_fun(s, x) = x -- otherwise
125132;; Types
126133
127134def $subst_typ(subst, typ) : typ
128- def $subst_typ(s, t) = t' -- if (t', s') = $subst_refresh_typ(s, t)
129-
130- def $subst_refresh_typ(subst, typ) : (typ, subst)
131- def $subst_refresh_typ(s, VAR x a*) = (t, {}) -- if (x,t) <- s.TYP /\ a* = eps
132- def $subst_refresh_typ(s, VAR x a*) = (VAR x $subst_arg(s, a)*, {}) -- otherwise
133- def $subst_refresh_typ(s, optyp) = (optyp, {})
134- def $subst_refresh_typ(s, TUP tb*) = (TUP $subst_typbind(s, tb')*, s')
135- -- if (tb'*, s') = $refresh_typbinds(tb*)
136- def $subst_refresh_typ(s, ITER t it) = (ITER $subst_typ(s ++ s', t) $subst_iter(s, it'), {})
137- -- if (it', s') = $refresh_iter(it)
138- def $subst_refresh_typ(s, MATCH x a* WITH inst*) = (MATCH x $subst_arg(s, a)* WITH $subst_inst(s, inst)*, {})
135+ def $subst_typ(s, VAR x a*) = t -- if (x,t) <- s.TYP /\ a* = eps
136+ def $subst_typ(s, VAR x a*) = VAR x $subst_arg(s, a)* -- otherwise
137+ def $subst_typ(s, optyp) = optyp
138+ def $subst_typ(s, TUP tb*) = TUP $subst_typbind(s, tb)*
139+ def $subst_typ(s, ITER t it) = ITER $subst_typ(s ++ s', t) $subst_iter(s, it')
140+ def $subst_typ(s, MATCH x a* WITH inst*) = MATCH x $subst_arg(s, a)* WITH $subst_inst(s, inst)*
139141
140142def $subst_deftyp(subst, deftyp) : deftyp
141143def $subst_deftyp(s, ALIAS t) = ALIAS $subst_typ(s, t)
142- def $subst_deftyp(s, STRUCT (a `: t `- `{q*} pr*)*) = STRUCT (a `: t' `- `{$subst_param(s ++ s', q')*} $subst_prem(s ++ s' ++ s'', pr)*)*
143- -- if (t', s') = $subst_refresh_typ(s, t)
144+ def $subst_deftyp(s, STRUCT (a `: t `- `{q*} pr*)*) = STRUCT (a `: $subst_typ(s, t') `- `{$subst_param(s ++ s', q')*} $subst_prem(s ++ s' ++ s'', pr)*)*
145+ -- if (t', s') = $refresh_typ( t)
144146 -- if (q'*, s'') = $refresh_params(q*)
145- def $subst_deftyp(s, VARIANT (m `: t `- `{q*} pr*)*) = VARIANT (m `: t' `- `{$subst_param(s ++ s', q')*} $subst_prem(s ++ s' ++ s'', pr)*)*
146- -- if (t', s') = $subst_refresh_typ(s, t)
147+ def $subst_deftyp(s, VARIANT (m `: t `- `{q*} pr*)*) = VARIANT (m `: $subst_typ(s, t') `- `{$subst_param(s ++ s', q')*} $subst_prem(s ++ s' ++ s'', pr)*)*
148+ -- if (t', s') = $refresh_typ( t)
147149 -- if (q'*, s'') = $refresh_params(q*)
148150
149151def $subst_typbind(subst, typbind) : typbind
0 commit comments