more uniform use of Properties.Eq.unapply, with slightly changed semantics in boundary cases;
authorwenzelm
Mon, 17 May 2021 14:54:03 +0200
changeset 73716 00ef0f401a29
parent 73715 bf51c23f3f99
child 73717 2f4cb9cb087f
more uniform use of Properties.Eq.unapply, with slightly changed semantics in boundary cases;
src/Pure/General/http.scala
src/Pure/ML/ml_statistics.scala
src/Pure/System/isabelle_platform.scala
--- a/src/Pure/General/http.scala	Mon May 17 14:07:51 2021 +0200
+++ b/src/Pure/General/http.scala	Mon May 17 14:54:03 2021 +0200
@@ -200,10 +200,10 @@
   sealed case class Arg(method: String, uri: URI, request: Bytes)
   {
     def decode_properties: Properties.T =
-      space_explode('&', request.text).map(s =>
-        space_explode('=', s) match {
-          case List(a, b) => Url.decode(a) -> Url.decode(b)
-          case _ => error("Malformed key-value pair in HTTP/POST: " + quote(s))
+      space_explode('&', request.text).map(
+        {
+          case Properties.Eq(a, b) => Url.decode(a) -> Url.decode(b)
+          case s => error("Malformed key-value pair in HTTP/POST: " + quote(s))
         })
   }
 
--- a/src/Pure/ML/ml_statistics.scala	Mon May 17 14:07:51 2021 +0200
+++ b/src/Pure/ML/ml_statistics.scala	Mon May 17 14:54:03 2021 +0200
@@ -58,12 +58,7 @@
   {
     def progress_stdout(line: String): Unit =
     {
-      val props =
-        Library.space_explode(',', line).flatMap((entry: String) =>
-          Library.space_explode('=', entry) match {
-            case List(a, b) => Some((a, b))
-            case _ => None
-          })
+      val props = Library.space_explode(',', line).flatMap(Properties.Eq.unapply)
       if (props.nonEmpty) consume(props)
     }
 
--- a/src/Pure/System/isabelle_platform.scala	Mon May 17 14:07:51 2021 +0200
+++ b/src/Pure/System/isabelle_platform.scala	Mon May 17 14:54:03 2021 +0200
@@ -29,10 +29,7 @@
         val result = ssh.execute("bash -c " + Bash.string(script)).check
         new Isabelle_Platform(
           result.out_lines.map(line =>
-            space_explode('=', line) match {
-              case List(a, b) => (a, b)
-              case _ => error("Bad output: " + quote(result.out))
-            }))
+            Properties.Eq.unapply(line) getOrElse error("Bad output: " + quote(result.out))))
     }
   }