src/HOL/BNF/Tools/bnf_fp_def_sugar.ML
changeset 51769 5c657ca97d99
parent 51768 d2a236b10796
child 51777 48a0ae342ea0
equal deleted inserted replaced
51768:d2a236b10796 51769:5c657ca97d99
   182 
   182 
   183     (* TODO: cleaner handling of fake contexts, without "background_theory" *)
   183     (* TODO: cleaner handling of fake contexts, without "background_theory" *)
   184     (*the "perhaps o try" below helps gracefully handles the case where the new type is defined in a
   184     (*the "perhaps o try" below helps gracefully handles the case where the new type is defined in a
   185       locale and shadows an existing global type*)
   185       locale and shadows an existing global type*)
   186 
   186 
   187     fun add_fake_type spec mixfix =
   187     fun add_fake_type spec =
   188       Sign.add_type no_defs_lthy (type_binding_of spec,
   188       Sign.add_type no_defs_lthy (type_binding_of spec,
   189         length (type_args_named_constrained_of spec), mixfix);
   189         length (type_args_named_constrained_of spec), mixfix_of spec);
   190 
   190 
   191     val fake_thy =
   191     val fake_thy = Theory.copy #> fold add_fake_type specs;
   192       Theory.copy #> fold (fn spec => fn thy =>
       
   193           case try (add_fake_type spec (mixfix_of spec)) thy of
       
   194             SOME thy' => thy'
       
   195           | NONE => add_fake_type spec Mixfix.NoSyn thy)
       
   196         specs;
       
   197     val fake_lthy = Proof_Context.background_theory fake_thy no_defs_lthy;
   192     val fake_lthy = Proof_Context.background_theory fake_thy no_defs_lthy;
   198 
   193 
   199     fun mk_fake_T b =
   194     fun mk_fake_T b =
   200       Type (fst (Term.dest_Type (Proof_Context.read_type_name fake_lthy true (Binding.name_of b))),
   195       Type (fst (Term.dest_Type (Proof_Context.read_type_name fake_lthy true (Binding.name_of b))),
   201         unsorted_As);
   196         unsorted_As);