julianpeeters / typename   0.2.0

Apache License 2.0 GitHub

Get names for common types, without the use of reflection.

Scala versions: 3.x
Scala.js versions: 1.x
Scala Native versions: 0.4

typename

Get names for common types using typeclasses instead of reflection.

Add the dependency:

  • libarary for Scala 3 (JS, JVM, and Native platforms)
"com.julianpeeters" %% "typename" % "0.2.0"

Example:

import typename.{NameOf, given}

val str: String = summon[NameOf[Some[Int]]].name
// str: String = "Some[Int]"

Supported types:

click to expand
Primitive:
  • Boolean
  • Byte
  • Char
  • Int
  • Long
  • Nothing
  • String
  • Unit
Complex:
  • Array
  • Either
  • Function (1-9)
  • List
  • Option
  • Tuple (2-9)