Given:
case class Foo(a: Option[Int], b: Option[Int], c: Option[Int], d: Option[Int])
I'd like to only allow constructing a Foo
only if at least one of its arguments is Some
, i.e. not all fields are None
.
It would be quite a bit of code to write an Algebraic Data Type, and then make sub-classes for each variant:
sealed trait Foo
case class HasAOnly(a: Int) extends Foo
case class HasAB(a: Int, b: Int) extends Foo
// etc...
Is there a cleaner, i.e. less code, way to address my problem using shapeless
?