Skip to content

Commit

Permalink
fix ClassyOptics for parametric types, add representable for service …
Browse files Browse the repository at this point in the history
…logging
  • Loading branch information
Oleg Nizhnik committed Dec 19, 2019
1 parent fe7c7e0 commit 5e01cdf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Publish._, Dependencies._
import com.typesafe.sbt.SbtGit.git

val libVersion = "0.5.7"
val libVersion = "0.5.7.1"

lazy val setMinorVersion = minorVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
Expand Down
8 changes: 8 additions & 0 deletions logging/structured/src/main/scala/tofu/logging/Logging.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ trait LoggingBase[F[_]] {
/** Logging marked with Service type*/
trait ServiceLogging[F[_], +Service] extends LoggingBase[F]

object ServiceLogging{
private [this] val representableAny: RepresentableK[ServiceLogging[*[_], Any]] =
higherKind.derived.genRepresentableK[ServiceLogging[*[_], Any]]

final implicit def serviceLoggingRepresentable[Svc] : RepresentableK[ServiceLogging[*[_], Any]] =
representableAny.asInstanceOf[RepresentableK[ServiceLogging[*[_], Any]]]
}

/** typeclass for logging using specified logger or set of loggers
* see `Logs` for creating instances of that*/
trait Logging[F[_]] extends ServiceLogging[F, Nothing] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private[macros] class OpticsImpl(val c: blackbox.Context) {

lazy val (resClassy, classyT) = labelClass(param, res)(s, s, a, a)
if (classy) q"implicit def $lensName[..$tparams] : $classyT = $resClassy"
q"""def $lensName[..$tparams] = $res"""
else q"""def $lensName[..$tparams] = $res"""
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ object TestClassyContains {
implicitly[Contains[FooBar4[Double], String]]
implicitly[Update[FooBar4[Double], String]]
implicitly[PContains[FooBar4[Double], FooBar4[Long], Double, Long] with Label["x"]]
implicitly[Contains[FooBar5[String], List[String]] with Label["x"]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ case class Foo(b: Bar)

@POptics("contains_") case class FooBar3[X](i: Int, j: String, x: X)
@ClassyPOptics("contains_") case class FooBar4[X](i: Int, j: String, x: X)
@ClassyOptics case class FooBar5[Y](i: Int, j: String, x: List[Y])

0 comments on commit 5e01cdf

Please sign in to comment.