From 89478a78f807d9bb28dcf6bdc60a16a391a3524c Mon Sep 17 00:00:00 2001 From: Jon Pretty Date: Thu, 28 Dec 2017 11:56:11 +0000 Subject: Scala-fmt updates --- examples/shared/src/main/scala/default.scala | 2 +- examples/shared/src/main/scala/show.scala | 19 +++++++++++++++---- examples/shared/src/main/scala/typename.scala | 3 +-- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'examples/shared/src/main/scala') diff --git a/examples/shared/src/main/scala/default.scala b/examples/shared/src/main/scala/default.scala index bce11d6..e05af52 100644 --- a/examples/shared/src/main/scala/default.scala +++ b/examples/shared/src/main/scala/default.scala @@ -14,7 +14,7 @@ object Default { /** constructs a default for each parameter, using the constructor default (if provided), * otherwise using a typeclass-provided default */ - def combine[T](ctx: CaseClass[Default, T, Param[Default, T]]): Default[T] = new Default[T] { + def combine[T](ctx: CaseClass[Default, T]): Default[T] = new Default[T] { def default = ctx.construct { param => param.default.getOrElse(param.typeclass.default) } diff --git a/examples/shared/src/main/scala/show.scala b/examples/shared/src/main/scala/show.scala index ee43dfc..b6b546d 100644 --- a/examples/shared/src/main/scala/show.scala +++ b/examples/shared/src/main/scala/show.scala @@ -34,22 +34,33 @@ trait GenericShow[Out] { def join(typeName: String, strings: Seq[String]): Out - def param[T, P](name: String, typeclass: Show[Out, P], dereference: T => P)(implicit auto: Dflt[P]) = + def param[T, P](name: String, typeclass: Show[Out, P], dereference: T => P)( + implicit auto: Dflt[P] + ) = ShowParam[Out, T, P](name, typeclass, dereference) def caseClass[T, P](name: String, parameters: Array[P], isValueClass: Boolean): Derivation[T, P] = Derivation(name, isValueClass, parameters) - /*def subtype[T, S <: T](name: String, typeclassParam: => Show[Out, S], isType: T => Boolean, asType: T => S): Subtype[Typeclass, T] = + def subtype[T, S <: T](name: String, + typeclass: => Show[Out, S], + isType: T => Boolean, + asType: T => S): Subtype[Typeclass, T] = { + def typeclassVal = typeclass new Subtype[Typeclass, T] { type SType = S def label = name - def typeclass = typeclassParam + def typeclass = typeclassVal def cast = new PartialFunction[T, S] { def isDefinedAt(t: T) = isType(t) def apply(t: T): SType = asType(t) } - }*/ + } + } + + def sealedTrait[T](name: String, + subtypes: Array[Subtype[Typeclass, T]]): SealedTrait[Typeclass, T] = + new SealedTrait[Typeclass, T](name, subtypes) /** creates a new [[Show]] instance by labelling and joining (with `mkString`) the result of * showing each parameter, and prefixing it with the class name */ diff --git a/examples/shared/src/main/scala/typename.scala b/examples/shared/src/main/scala/typename.scala index aaa40f7..cdc4b01 100644 --- a/examples/shared/src/main/scala/typename.scala +++ b/examples/shared/src/main/scala/typename.scala @@ -8,7 +8,7 @@ trait TypeName[T] { def name: String } object TypeName { type Typeclass[T] = TypeName[T] - def combine[T](ctx: CaseClass[TypeName, T, _]): TypeName[T] = + def combine[T](ctx: CaseClass[TypeName, T]): TypeName[T] = new TypeName[T] { def name: String = ctx.typeName } def dispatch[T](ctx: SealedTrait[TypeName, T]): TypeName[T] = @@ -16,4 +16,3 @@ object TypeName { implicit def gen[T]: TypeName[T] = macro Magnolia.gen[T] } - -- cgit v1.2.3