clarified signature: separate formal context from exported theory_name;
authorwenzelm
Fri, 07 Jun 2024 11:44:15 +0200
changeset 80287 a3a1ec0c47ab
parent 80286 00d68f324056
child 80288 bc48bc7d0801
clarified signature: separate formal context from exported theory_name;
src/Pure/Build/export.ML
src/Pure/Tools/generated_files.ML
src/Pure/proofterm.ML
--- a/src/Pure/Build/export.ML	Fri Jun 07 11:10:49 2024 +0200
+++ b/src/Pure/Build/export.ML	Fri Jun 07 11:44:15 2024 +0200
@@ -6,10 +6,10 @@
 
 signature EXPORT =
 sig
-  val report_export: theory -> Path.binding -> unit
+  val report: Context.generic -> string -> Path.binding -> unit
   type params =
-    {theory: theory, binding: Path.binding, executable: bool, compress: bool, strict: bool}
-  val export_params: params -> XML.body -> unit
+    {theory_name: string, binding: Path.binding, executable: bool, compress: bool, strict: bool}
+  val export_params: Context.generic -> params -> XML.body -> unit
   val export: theory -> Path.binding -> XML.body -> unit
   val export_executable: theory -> Path.binding -> XML.body -> unit
   val export_file: theory -> Path.binding -> Path.T -> unit
@@ -23,34 +23,35 @@
 
 (* export *)
 
-fun report_export thy binding =
+fun report context theory_name binding =
   let
-    val theory_name = Context.theory_long_name thy;
     val (path, pos) = Path.dest_binding binding;
     val markup = Markup.export_path (Path.implode (Path.basic theory_name + path));
-  in Context_Position.report_generic (Context.Theory thy) pos markup end;
+  in Context_Position.report_generic context pos markup end;
 
 type params =
-  {theory: theory, binding: Path.binding, executable: bool, compress: bool, strict: bool};
+  {theory_name: string, binding: Path.binding, executable: bool, compress: bool, strict: bool};
 
-fun export_params ({theory = thy, binding, executable, compress, strict}: params) body =
- (report_export thy binding;
+fun export_params context ({theory_name, binding, executable, compress, strict}: params) body =
+ (report context theory_name binding;
   (Output.try_protocol_message o Markup.export)
    {id = Position.id_of (Position.thread_data ()),
     serial = serial (),
-    theory_name = Context.theory_long_name thy,
+    theory_name = theory_name,
     name = Path.implode_binding (tap Path.proper_binding binding),
     executable = executable,
     compress = compress,
     strict = strict} [body]);
 
 fun export thy binding body =
-  export_params
-    {theory = thy, binding = binding, executable = false, compress = true, strict = true} body;
+  export_params (Context.Theory thy)
+    {theory_name = Context.theory_long_name thy, binding = binding,
+      executable = false, compress = true, strict = true} body;
 
 fun export_executable thy binding body =
-  export_params
-    {theory = thy, binding = binding, executable = true, compress = true, strict = true} body;
+  export_params (Context.Theory thy)
+    {theory_name = Context.theory_long_name thy, binding = binding,
+      executable = true, compress = true, strict = true} body;
 
 fun export_file thy binding file =
   export thy binding (Bytes.contents_blob (Bytes.read file));
--- a/src/Pure/Tools/generated_files.ML	Fri Jun 07 11:10:49 2024 +0200
+++ b/src/Pure/Tools/generated_files.ML	Fri Jun 07 11:44:15 2024 +0200
@@ -349,7 +349,8 @@
                 (case try Bytes.read (dir + path) of
                   SOME bytes => Bytes.contents_blob bytes
                 | NONE => error ("Missing result file " ^ Path.print path ^ Position.here pos));
-              val _ = Export.report_export thy export_prefix;
+              val _ =
+                Export.report (Context.Theory thy) (Context.theory_long_name thy) export_prefix;
               val binding' =
                 Path.map_binding (Path.append (Path.path_of_binding export_prefix)) binding;
             in
--- a/src/Pure/proofterm.ML	Fri Jun 07 11:10:49 2024 +0200
+++ b/src/Pure/proofterm.ML	Fri Jun 07 11:44:15 2024 +0200
@@ -2164,8 +2164,8 @@
         val encode_proof = encode_standard_proof consts;
       in pair (list (pair string sort)) (pair encode_vars (pair encode_term encode_proof)) end;
   in
-    Export.export_params
-     {theory = thy,
+    Export.export_params (Context.Theory thy)
+     {theory_name = Context.theory_long_name thy,
       binding = Path.binding0 (Path.make ["proofs", string_of_int i]),
       executable = false,
       compress = true,