tofu.logging.derivation.package.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tofu-logging-derivation_2.12 Show documentation
Show all versions of tofu-logging-derivation_2.12 Show documentation
Opinionated set of tools for functional programming in Scala
package tofu.logging
import magnolia1.TypeName
import scala.collection.compat._
package object derivation {
type MagnoliaParam[TC[_], T] = magnolia1.Param[TC, T]
private[derivation] def strJoin(typeName: String, strings: IterableOnce[String]): String =
if (strings.iterator.isEmpty) typeName else strings.iterator.mkString(s"$typeName{", ",", "}")
private[derivation] def calcTypeName(typeName: TypeName, seen: Set[TypeName] = Set()): String =
if (seen(typeName)) "#"
else {
val args = typeName.typeArguments
val name = typeName.full
if (args.isEmpty) name
else args.iterator.map(calcTypeName(_, seen + typeName)).mkString(name + "[", ",", "]")
}
}