diff options
author | Jon Pretty <jon.pretty@propensive.com> | 2017-12-28 11:56:11 +0000 |
---|---|---|
committer | Jon Pretty <jon.pretty@propensive.com> | 2017-12-28 11:56:11 +0000 |
commit | 89478a78f807d9bb28dcf6bdc60a16a391a3524c (patch) | |
tree | b48b1dd51343ae0563082b2f38ec0f5252ce0e0b /examples/shared/src/main/scala/show.scala | |
parent | bd5f2dc411b1d63b9ee4dfec6476ba27d8410e2a (diff) | |
download | magnolia-virtual-params.tar.gz magnolia-virtual-params.tar.bz2 magnolia-virtual-params.zip |
Scala-fmt updatesvirtual-params
Diffstat (limited to 'examples/shared/src/main/scala/show.scala')
-rw-r--r-- | examples/shared/src/main/scala/show.scala | 19 |
1 files changed, 15 insertions, 4 deletions
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 */ |