equal
deleted
inserted
replaced
5 Compatibility layer with the old datatype package. |
5 Compatibility layer with the old datatype package. |
6 *) |
6 *) |
7 |
7 |
8 signature BNF_LFP_COMPAT = |
8 signature BNF_LFP_COMPAT = |
9 sig |
9 sig |
10 val datatype_new_compat_cmd : string list -> local_theory -> local_theory |
10 val datatype_compat_cmd : string list -> local_theory -> local_theory |
11 end; |
11 end; |
12 |
12 |
13 structure BNF_LFP_Compat : BNF_LFP_COMPAT = |
13 structure BNF_LFP_Compat : BNF_LFP_COMPAT = |
14 struct |
14 struct |
15 |
15 |
22 val compatN = "compat_"; |
22 val compatN = "compat_"; |
23 |
23 |
24 val code_nitpicksimp_simp_attrs = Code.add_default_eqn_attrib :: @{attributes [nitpick_simp, simp]}; |
24 val code_nitpicksimp_simp_attrs = Code.add_default_eqn_attrib :: @{attributes [nitpick_simp, simp]}; |
25 |
25 |
26 (* TODO: graceful failure for local datatypes -- perhaps by making the command global *) |
26 (* TODO: graceful failure for local datatypes -- perhaps by making the command global *) |
27 fun datatype_new_compat_cmd raw_fpT_names lthy = |
27 fun datatype_compat_cmd raw_fpT_names lthy = |
28 let |
28 let |
29 val thy = Proof_Context.theory_of lthy; |
29 val thy = Proof_Context.theory_of lthy; |
30 |
30 |
31 fun not_datatype s = error (quote s ^ " is not a new-style datatype"); |
31 fun not_datatype s = error (quote s ^ " is not a new-style datatype"); |
32 fun not_mutually_recursive ss = |
32 fun not_mutually_recursive ss = |
201 |> Local_Theory.raw_theory register_interpret |
201 |> Local_Theory.raw_theory register_interpret |
202 |> Local_Theory.notes all_notes |> snd |
202 |> Local_Theory.notes all_notes |> snd |
203 end; |
203 end; |
204 |
204 |
205 val _ = |
205 val _ = |
206 Outer_Syntax.local_theory @{command_spec "datatype_new_compat"} |
206 Outer_Syntax.local_theory @{command_spec "datatype_compat"} |
207 "register new-style datatypes as old-style datatypes" |
207 "register new-style datatypes as old-style datatypes" |
208 (Scan.repeat1 Parse.type_const >> datatype_new_compat_cmd); |
208 (Scan.repeat1 Parse.type_const >> datatype_compat_cmd); |
209 |
209 |
210 end; |
210 end; |