blob: 2283ce0141c5ad8b7fa9a44f4b0a6fb7ae3438cb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package magnolia.examples
import scala.collection.immutable.ListMap
import scala.language.experimental.macros
import cats.Show
import magnolia.{Coderivation, Macros}
object catsShowDerivation {
val ShowDerivation = new Coderivation[Show] {
type Return = String
def call[T](show: Show[T], value: T): String = show.show(value)
def construct[T](body: T => String): Show[T] = body(_)
def join(name: String, xs: ListMap[String, String]): String =
xs.map { case (k, v) => s"$k=$v" }.mkString(s"$name(", ", ", ")")
}
}
|