equal
deleted
inserted
replaced
22 val get_constrs : theory -> string -> (string * typ) list option |
22 val get_constrs : theory -> string -> (string * typ) list option |
23 val mk_case_names_induct: descr -> attribute |
23 val mk_case_names_induct: descr -> attribute |
24 val mk_case_names_exhausts: descr -> string list -> attribute list |
24 val mk_case_names_exhausts: descr -> string list -> attribute list |
25 val interpretation : (config -> string list -> theory -> theory) -> theory -> theory |
25 val interpretation : (config -> string list -> theory -> theory) -> theory -> theory |
26 val interpretation_data : config * string list -> theory -> theory |
26 val interpretation_data : config * string list -> theory -> theory |
27 val make_case : Proof.context -> Datatype_Case.config -> string list -> term -> |
|
28 (term * term) list -> term |
|
29 val strip_case : Proof.context -> bool -> term -> (term * (term * term) list) option |
|
30 val add_case_tr' : string list -> theory -> theory |
|
31 val setup: theory -> theory |
27 val setup: theory -> theory |
32 end; |
28 end; |
33 |
29 |
34 structure Datatype_Data: DATATYPE_DATA = |
30 structure Datatype_Data: DATATYPE_DATA = |
35 struct |
31 struct |
194 fun mk_case_names_exhausts descr new = |
190 fun mk_case_names_exhausts descr new = |
195 map (Rule_Cases.case_names o exhaust_cases descr o #1) |
191 map (Rule_Cases.case_names o exhaust_cases descr o #1) |
196 (filter (fn ((_, (name, _, _))) => member (op =) new name) descr); |
192 (filter (fn ((_, (name, _, _))) => member (op =) new name) descr); |
197 |
193 |
198 end; |
194 end; |
199 |
|
200 |
|
201 (* translation rules for case *) |
|
202 |
|
203 fun make_case ctxt = |
|
204 Datatype_Case.make_case (info_of_constr_permissive (Proof_Context.theory_of ctxt)) ctxt; |
|
205 |
|
206 fun strip_case ctxt = |
|
207 Datatype_Case.strip_case (info_of_case (Proof_Context.theory_of ctxt)); |
|
208 |
|
209 fun add_case_tr' case_names thy = |
|
210 Sign.add_advanced_trfuns ([], [], |
|
211 map (fn case_name => |
|
212 let val case_name' = Lexicon.mark_const case_name in |
|
213 (case_name', Datatype_Case.case_tr' info_of_case case_name') |
|
214 end) case_names, []) thy; |
|
215 |
|
216 val trfun_setup = |
|
217 Sign.add_advanced_trfuns ([], |
|
218 [(@{syntax_const "_case_syntax"}, Datatype_Case.case_tr true info_of_constr_permissive)], |
|
219 [], []); |
|
220 |
195 |
221 |
196 |
222 |
197 |
223 (** document antiquotation **) |
198 (** document antiquotation **) |
224 |
199 |
260 |
235 |
261 |
236 |
262 (** setup theory **) |
237 (** setup theory **) |
263 |
238 |
264 val setup = |
239 val setup = |
265 trfun_setup #> |
|
266 antiq_setup #> |
240 antiq_setup #> |
267 Datatype_Interpretation.init; |
241 Datatype_Interpretation.init; |
268 |
242 |
269 open Datatype_Aux; |
243 open Datatype_Aux; |
270 |
244 |