src/HOL/Tools/inductive_package.ML
changeset 17261 193b84a70ca4
parent 17057 0934ac31985f
child 17325 d9d50222808e
equal deleted inserted replaced
17260:df7c3b1f390a 17261:193b84a70ca4
   110 val print_inductives = InductiveData.print;
   110 val print_inductives = InductiveData.print;
   111 
   111 
   112 
   112 
   113 (* get and put data *)
   113 (* get and put data *)
   114 
   114 
   115 fun get_inductive thy name = Symtab.lookup (fst (InductiveData.get thy), name);
   115 val get_inductive = Symtab.curried_lookup o #1 o InductiveData.get;
   116 
   116 
   117 fun the_inductive thy name =
   117 fun the_inductive thy name =
   118   (case get_inductive thy name of
   118   (case get_inductive thy name of
   119     NONE => error ("Unknown (co)inductive set " ^ quote name)
   119     NONE => error ("Unknown (co)inductive set " ^ quote name)
   120   | SOME info => info);
   120   | SOME info => info);
   121 
   121 
   122 val the_mk_cases = (#mk_cases o #2) oo the_inductive;
   122 val the_mk_cases = (#mk_cases o #2) oo the_inductive;
   123 
   123 
   124 fun put_inductives names info thy =
   124 fun put_inductives names info thy =
   125   let
   125   let
   126     fun upd ((tab, monos), name) = (Symtab.update_new ((name, info), tab), monos);
   126     fun upd ((tab, monos), name) = (Symtab.curried_update_new (name, info) tab, monos);
   127     val tab_monos = Library.foldl upd (InductiveData.get thy, names)
   127     val tab_monos = Library.foldl upd (InductiveData.get thy, names)
   128       handle Symtab.DUP name => error ("Duplicate definition of (co)inductive set " ^ quote name);
   128       handle Symtab.DUP name => error ("Duplicate definition of (co)inductive set " ^ quote name);
   129   in InductiveData.put tab_monos thy end;
   129   in InductiveData.put tab_monos thy end;
   130 
   130 
   131 
   131