aboutsummaryrefslogtreecommitdiff
path: root/examples/src/main/scala/show.scala
diff options
context:
space:
mode:
Diffstat (limited to 'examples/src/main/scala/show.scala')
-rw-r--r--examples/src/main/scala/show.scala19
1 files changed, 10 insertions, 9 deletions
diff --git a/examples/src/main/scala/show.scala b/examples/src/main/scala/show.scala
index fdebb78..50b34ee 100644
--- a/examples/src/main/scala/show.scala
+++ b/examples/src/main/scala/show.scala
@@ -21,16 +21,17 @@ trait GenericShow[Out] {
/** creates a new [[Show]] instance by labelling and joining (with `mkString`) the result of
* showing each parameter, and prefixing it with the class name */
def combine[T](ctx: CaseClass[Typeclass, T]): Show[Out, T] = new Show[Out, T] {
- def show(value: T) = if(ctx.isValueClass) {
- val param = ctx.parameters.head
- param.typeclass.show(param.dereference(value))
- } else {
- val paramStrings = ctx.parameters.map { param =>
- s"${param.label}=${param.typeclass.show(param.dereference(value))}"
+ def show(value: T) =
+ if (ctx.isValueClass) {
+ val param = ctx.parameters.head
+ param.typeclass.show(param.dereference(value))
+ } else {
+ val paramStrings = ctx.parameters.map { param =>
+ s"${param.label}=${param.typeclass.show(param.dereference(value))}"
+ }
+
+ join(ctx.typeName.split("\\.").last, paramStrings)
}
-
- join(ctx.typeName.split("\\.").last, paramStrings)
- }
}
/** choose which typeclass to use based on the subtype of the sealed trait */