Generation of arbitrary case classes / ADTs with scalacheck and shapeless
alexarchambault on scala-cli
Switch build to Scala CLI Use Scala CLI nightly (compare)
alexarchambault on master
Update sbt to 1.6.2 (#246) * A… (compare)
alexarchambault on scala-cli
Use Scala CLI nightly (compare)
alexarchambault on sbt-main-line
Use sbt main line launcher on CI (compare)
alexarchambault on scala-cli
Switch build to Scala CLI (compare)
alexarchambault on scala-cli
Switch build to Scala CLI (compare)
alexarchambault on sbt-main-line
alexarchambault on master
Use sbt main line launcher on C… (compare)
alexarchambault on sbt-main-line
Use sbt main line launcher on CI (compare)
alexarchambault on scala-cli
Switch build to Scala CLI (compare)
Lazy
effectively turns off scalac's checks for implicit divergence. On the plus side that means we can build recursive instances (for recursive data types). On the minus side, that means that it is possible to make the typechecker loop if resolution doesn't actually converge.
Lazy
-based)
Arbitrary
for String @@ Baz
implicit def arbTaggedString[T]: Arbitrary[String @@ T] = Arbitrary(arbitrary[String].map(a => tag[T](a)))
T @@ Baz
)
implicit val stringArb: Arbitrary[String] = Arbitrary(Arbitrary.arbitrary[String] suchThat (_ != ""))
looks like it works
I’m “generating” Arbitrary
s instances for several data structures that are basically sealed traits hierarchies that include cases classes, which have parameters that are sealed traits hierarchies as well — different ones
The compile times are horrendous. The PoC was with all the Arbitrary
instances declared in the same file, and the dependencies among them were handled “globally”… until that stopped working, i.e. it never finishes compiling.
I’m trying to make it the most modular as possible, any recomendation? (I’m hopping for hidden tricks and caveats)
I’d like to be only able to create an instance of Arbitrary
of a sealed trait hierarchy, if all the parameters if the children have explicit-implicit Arbitrary
s, e.g.
case class TimeConstraint( t:LocalTime, m:Modifier, a:Activity )
implicit def timeConstraintArb(
implicit
lt: Arbitrary[LocalTime],
m: Arbitrary[Modifier],
a: Arbitrary[Activity]
):Arbitrary[TimeConstraint]
where Modifer
and Activity
are also sealed traits
the goal is that this method does not compile if the instances are not present…
for example, this version with out Arbitrary[Activity]
implicit def timeConstraintArb(
implicit
lt: Arbitrary[LocalTime],
m: Arbitrary[Modifier]
):Arbitrary[TimeConstraint]
should not compile.
But if I just add import org.scalacheck.Shapeless._
in the method body, then it will “just work”, which is undesirable here...