aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKevin Wright <kevin.wright@bradyplc.com>2018-02-08 21:20:53 +0000
committerKevin Wright <kevin.wright@bradyplc.com>2018-02-08 21:20:53 +0000
commitc1b9c1f53a6bb3f62abc7141e6b6153d8208e1f0 (patch)
treee867d326898b1e7d0019753728b921c3a160167c /examples
parent6660480a75b240b7ac613ed308e5b7f7ddfc6459 (diff)
downloadmagnolia-c1b9c1f53a6bb3f62abc7141e6b6153d8208e1f0.tar.gz
magnolia-c1b9c1f53a6bb3f62abc7141e6b6153d8208e1f0.tar.bz2
magnolia-c1b9c1f53a6bb3f62abc7141e6b6153d8208e1f0.zip
post-review changes
Diffstat (limited to 'examples')
-rw-r--r--examples/shared/src/main/scala/decode.scala8
-rw-r--r--examples/shared/src/main/scala/show.scala2
2 files changed, 5 insertions, 5 deletions
diff --git a/examples/shared/src/main/scala/decode.scala b/examples/shared/src/main/scala/decode.scala
index 9e91d17..539e478 100644
--- a/examples/shared/src/main/scala/decode.scala
+++ b/examples/shared/src/main/scala/decode.scala
@@ -10,10 +10,10 @@ trait Decoder[T] { def decode(str: String): T }
object Decoder {
/** decodes strings */
- implicit val string: Decoder[String] = (str: String) => str
+ implicit val string: Decoder[String] = (s: String) => s
/** decodes ints */
- implicit val int: Decoder[Int] = (str: String) => str.toInt
+ implicit val int: Decoder[Int] = _.toInt
/** binds the Magnolia macro to this derivation object */
implicit def gen[T]: Decoder[T] = macro Magnolia.gen[T]
@@ -22,7 +22,7 @@ object Decoder {
type Typeclass[T] = Decoder[T]
/** defines how new [[Decoder]]s for case classes should be constructed */
- def combine[T](ctx: CaseClass[Decoder, T]): Decoder[T] = (value: String) => {
+ def combine[T](ctx: CaseClass[Decoder, T]): Decoder[T] = value => {
val (_, values) = parse(value)
ctx.construct { param =>
param.typeclass.decode(values(param.label))
@@ -30,7 +30,7 @@ object Decoder {
}
/** defines how to choose which subtype of the sealed trait to use for decoding */
- def dispatch[T](ctx: SealedTrait[Decoder, T]): Decoder[T] = (param: String) => {
+ def dispatch[T](ctx: SealedTrait[Decoder, T]): Decoder[T] = param => {
val (name, _) = parse(param)
val subtype = ctx.subtypes.find(_.typeName.full == name).get
subtype.typeclass.decode(param)
diff --git a/examples/shared/src/main/scala/show.scala b/examples/shared/src/main/scala/show.scala
index 9afc4c9..ecf1dec 100644
--- a/examples/shared/src/main/scala/show.scala
+++ b/examples/shared/src/main/scala/show.scala
@@ -20,7 +20,7 @@ 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] = (value: T) => {
+ def combine[T](ctx: CaseClass[Typeclass, T]): Show[Out, T] = { value =>
if (ctx.isValueClass) {
val param = ctx.parameters.head
param.typeclass.show(param.dereference(value))