Scala 3 macros for converting multi-parameter functions into functions with named parameters or named-tuple arguments, preserving the original parameter names.
Available on Maven Central as org.polyvariant::named-functions.
In scala-cli:
//> using dep org.polyvariant::named-functions::<version>In sbt:
libraryDependencies += "org.polyvariant" %% "named-functions" % "<version>"In Mill:
ivy"org.polyvariant::named-functions:<version>"import namedfunctions.syntax.*
def foo(entityId: Int, userId: String): Boolean = ???
// Wrap a function so that its parameters are named at the call site
val f = foo.named
f(entityId = 1, userId = "hello")
// Convert a function into a Function1 from a named tuple
val g = foo.namedTupled
g((entityId = 1, userId = "hello"))Converts a multi-parameter function (a: A, b: B, ...) => R into a function with named parameters, preserving the original parameter names.
Like .tupled but the resulting tuple type carries the parameter names from the original method. Converts a multi-parameter function into a Function1 from a named tuple: ((a: A, b: B, ...)) => R.