more operations, following Isabelle/ML;
authorwenzelm
Sun, 09 Jun 2024 21:15:27 +0200
changeset 80312 b48768f9567f
parent 80311 31df11a23d6e
child 80313 a828e47c867c
more operations, following Isabelle/ML;
src/Pure/thm_name.scala
--- a/src/Pure/thm_name.scala	Sun Jun 09 20:47:30 2024 +0200
+++ b/src/Pure/thm_name.scala	Sun Jun 09 21:15:27 2024 +0200
@@ -30,6 +30,20 @@
       case Thm_Name_Regex(name, Value.Nat(index)) => Thm_Name(name, index)
       case _ => Thm_Name(s, 0)
     }
+
+
+  /* XML data representation */
+
+  def encode: XML.Encode.T[Thm_Name] = { (thm_name: Thm_Name) =>
+    import XML.Encode._
+    pair(string, int)((thm_name.name, thm_name.index))
+  }
+
+  def decode: XML.Decode.T[Thm_Name] = { (body: XML.Body) =>
+    import XML.Decode._
+    val (name, index) = pair(string, int)(body)
+    Thm_Name(name, index)
+  }
 }
 
 sealed case class Thm_Name(name: String, index: Int) {