-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Vadim Chelyshov <[email protected]>
- Loading branch information
Showing
93 changed files
with
736 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...-2/tofu/data/derived/InitDerivation.scala → ...la/tofu/data/derived/InitDerivation.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../tofu/data/derived/MerkatorFromCats.scala → .../tofu/data/derived/MerkatorFromCats.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions
5
modules/kernel/higherKind/src/main/scala-2/tofu/higherKind/Defs.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ package object higherKind { | |
type Pre[F[_], A] = Pre.T[F, A] | ||
|
||
type UnitK[A] = Unit | ||
|
||
type HKAny[_] = Any | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
modules/logging/derivation/src/main/scala-2/tofu/logging/derivation/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
modules/logging/derivation/src/main/scala-3/tofu/logging/derivation/loggable.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package tofu.logging | ||
package derivation | ||
|
||
import cats.Show | ||
import magnolia1.* | ||
|
||
object loggable extends AutoDerivation[Loggable] { | ||
|
||
def byShow[T: Show](name: String): Loggable[T] = | ||
Loggable.stringValue.contramap(Show[T].show).named(name) | ||
|
||
def join[T](ctx: CaseClass[Typeclass, T]): Loggable[T] = new DictLoggable[T] { | ||
private[this] val doNotShow = ctx.annotations.contains(hidden()) | ||
|
||
override val typeName: String = calcTypeName(ctx.typeInfo) | ||
override val shortName: String = ctx.typeInfo.short | ||
|
||
def fields[I, V, R, M](a: T, input: I)(implicit receiver: LogRenderer[I, V, R, M]): R = | ||
ctx.parameters.iterator | ||
.filter(!_.annotations.contains(hidden())) | ||
.foldLeft(receiver.noop(input)) { (acc, param) => | ||
import param._ | ||
|
||
val value = deref(a) | ||
typeclass match { | ||
case _ if annotations.contains(unembed()) => | ||
receiver.combine(acc, typeclass.fields(value, input)) | ||
case _ => | ||
annotations.collectFirst { case masked(mode) => | ||
receiver.combine(acc, typeclass.putMaskedField(value, label, input)(masking.string(_, mode))) | ||
}.getOrElse(receiver.combine(acc, typeclass.putField(value, label, input))) | ||
} | ||
} | ||
|
||
def logShow(value: T): String = | ||
if (doNotShow) "" | ||
else strJoin(ctx.typeInfo.short, masking.params[Typeclass, T](value, ctx.parameters)(_.logShow)) | ||
} | ||
|
||
def split[T](ctx: SealedTrait[Typeclass, T]): Loggable[T] = new Typeclass[T] { | ||
override val typeName: String = calcTypeName(ctx.typeInfo) | ||
override val shortName: String = ctx.typeInfo.short | ||
|
||
def fields[I, V, R, M](a: T, input: I)(implicit receiver: LogRenderer[I, V, R, M]): R = | ||
ctx.choose(a)(sub => sub.typeclass.fields(sub.cast(a), input)) | ||
|
||
def putValue[I, V, R, M](a: T, v: V)(implicit r: LogRenderer[I, V, R, M]): M = | ||
ctx.choose(a)(sub => sub.typeclass.putValue(sub.cast(a), v)) | ||
|
||
def logShow(a: T): String = | ||
ctx.choose(a)(sub => sub.typeclass.logShow(sub.cast(a))) | ||
|
||
override def putField[I, V, R, M](a: T, name: String, input: I)(implicit receiver: LogRenderer[I, V, R, M]): R = | ||
ctx.choose(a)(sub => sub.typeclass.putField(sub.cast(a), name, input)) | ||
} | ||
|
||
} |
Oops, something went wrong.