sealerate
sealerate copied to clipboard
Set of java.lang.Class extending sealed trait
Not sure if this is in the scope of this library, but would it be possible to get a Set of java.lang.Class extending the sealed trait
Do you mean like values.map(_.getClass)
?
Sorry I should have been more specific. the Set[java.lang.Class] would include case classes which are currently errored by values and filtered by collect. Something like caseClassValues: Set[java.lang.Class]
Thanks for the clarification. Does this rough example reflect more of what you'd want?
sealed trait Option[+A]
object Option {
case object None extends Option[Nothing]
final case class Some[A](a: A) extends Option[A]
def classes: Set[java.lang.Class[Option[_]]] = sealerate.classes[Option[_]]
}
Option.classes.map(_.getName).foreach(println)
// Results in:
// None
// Some
If so, can you give a code sample that reflects a non-contrived use-case for it?
Yes that is exactly it. One use case is for validating all implementations of a trait are in application.conf for akka.actor.serialization-bindings and generate a diff for errors. Maybe next would be reading the .conf in a macro also or update the .conf within a macro. Currently validating at runtime. I understand these other macros might be outside the scope of the library since it does not currently depend on Typesafe Config, but once I read up and practice more with Scala macros I can contribute a PR.