107 Local_Theory.target (Class_Target.refresh_syntax target); |
107 Local_Theory.target (Class_Target.refresh_syntax target); |
108 |
108 |
109 |
109 |
110 (* mixfix notation *) |
110 (* mixfix notation *) |
111 |
111 |
112 local |
|
113 |
|
114 fun fork_mixfix (Target {is_locale, is_class, ...}) mx = |
112 fun fork_mixfix (Target {is_locale, is_class, ...}) mx = |
115 if not is_locale then (NoSyn, NoSyn, mx) |
113 if not is_locale then (NoSyn, NoSyn, mx) |
116 else if not is_class then (NoSyn, mx, NoSyn) |
114 else if not is_class then (NoSyn, mx, NoSyn) |
117 else (mx, NoSyn, NoSyn); |
115 else (mx, NoSyn, NoSyn); |
118 |
116 |
119 in |
|
120 |
|
121 fun prep_mixfix ctxt ta (b, extra_tfrees) mx = |
|
122 let |
|
123 val mx' = |
|
124 if null extra_tfrees then mx |
|
125 else |
|
126 (warning |
|
127 ("Additional type variable(s) in specification of " ^ Binding.str_of b ^ ": " ^ |
|
128 commas (map (Syntax.string_of_typ ctxt o TFree) (sort_wrt #1 extra_tfrees)) ^ |
|
129 (if mx = NoSyn then "" |
|
130 else "\nDropping mixfix syntax " ^ Pretty.string_of (Syntax.pretty_mixfix mx))); |
|
131 NoSyn); |
|
132 in fork_mixfix ta mx' end; |
|
133 |
|
134 end; |
|
135 |
|
136 |
117 |
137 (* define *) |
118 (* define *) |
138 |
119 |
139 local |
120 local |
140 |
121 |
141 fun syntax_error c = error ("Illegal mixfix syntax for overloaded constant " ^ quote c); |
122 fun syntax_error c = error ("Illegal mixfix syntax for overloaded constant " ^ quote c); |
142 |
123 |
143 fun foundation (ta as Target {target, is_locale, is_class, ...}) |
124 fun foundation (ta as Target {target, is_locale, is_class, ...}) |
144 (((b, U), mx), (b_def, rhs')) params (extra_tfrees, type_params) lthy = |
125 (((b, U), mx), (b_def, rhs')) params type_params lthy = |
145 let |
126 let |
146 val (mx1, mx2, mx3) = prep_mixfix lthy ta (b, extra_tfrees) mx; |
127 val (mx1, mx2, mx3) = fork_mixfix ta mx; |
147 val (const, lthy2) = lthy |> |
128 val (const, lthy2) = lthy |> |
148 (case Class_Target.instantiation_param lthy b of |
129 (case Class_Target.instantiation_param lthy b of |
149 SOME c' => |
130 SOME c' => |
150 if mx3 <> NoSyn then syntax_error c' |
131 if mx3 <> NoSyn then syntax_error c' |
151 else Local_Theory.theory_result (AxClass.declare_overloaded (c', U)) |
132 else Local_Theory.theory_result (AxClass.declare_overloaded (c', U)) |
219 (Sign.add_abbrev Print_Mode.internal (b, t)) #-> |
200 (Sign.add_abbrev Print_Mode.internal (b, t)) #-> |
220 (fn (lhs, _) => locale_const_declaration ta prmode |
201 (fn (lhs, _) => locale_const_declaration ta prmode |
221 ((b, mx), Term.list_comb (Logic.unvarify_global lhs, xs))); |
202 ((b, mx), Term.list_comb (Logic.unvarify_global lhs, xs))); |
222 |
203 |
223 fun target_abbrev (ta as Target {target, is_locale, is_class, ...}) |
204 fun target_abbrev (ta as Target {target, is_locale, is_class, ...}) |
224 prmode (b, mx) (global_rhs, t') (extra_tfrees, xs) lthy = |
205 prmode (b, mx) (global_rhs, t') xs lthy = |
225 let |
206 let |
226 val (mx1, mx2, mx3) = prep_mixfix lthy ta (b, extra_tfrees) mx; |
207 val (mx1, mx2, mx3) = fork_mixfix ta mx; |
227 in if is_locale |
208 in if is_locale |
228 then lthy |
209 then lthy |
229 |> locale_abbrev ta prmode ((b, mx2), global_rhs) xs |
210 |> locale_abbrev ta prmode ((b, mx2), global_rhs) xs |
230 |> is_class ? class_target ta (Class_Target.abbrev target prmode ((b, mx1), t')) |
211 |> is_class ? class_target ta (Class_Target.abbrev target prmode ((b, mx1), t')) |
231 else lthy |
212 else lthy |