clarified signature: more operations;
authorwenzelm
Sat, 11 Nov 2023 20:01:14 +0100
changeset 78943 bc89bdc65f29
parent 78942 409442cb7814
child 78944 b0b86fead48c
clarified signature: more operations;
src/Pure/Tools/build_cluster.scala
src/Pure/library.scala
--- a/src/Pure/Tools/build_cluster.scala	Sat Nov 11 19:36:59 2023 +0100
+++ b/src/Pure/Tools/build_cluster.scala	Sat Nov 11 20:01:14 2023 +0100
@@ -88,6 +88,9 @@
           options = options)
       }
     }
+
+    def parse_single(str: String): Host =
+      Library.the_single(parse(str), "Single host expected: " + quote(str))
   }
 
   class Host(
--- a/src/Pure/library.scala	Sat Nov 11 19:36:59 2023 +0100
+++ b/src/Pure/library.scala	Sat Nov 11 20:01:14 2023 +0100
@@ -278,10 +278,10 @@
       res.toList
     }
 
-  def the_single[A](xs: List[A]): A =
+  def the_single[A](xs: List[A], message: => String = "Single argument expected"): A =
     xs match {
       case List(x) => x
-      case _ => error("Single argument expected")
+      case _ => error(message)
     }
 
   def symmetric_difference[A](xs: List[A], ys: List[A]): (List[A], List[A]) =