Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 14 14:04
    scala-steward opened #232
  • Oct 06 22:09
    scala-steward opened #231
  • Oct 06 14:04
    scala-steward opened #230
  • Oct 05 14:12

    alexarchambault on scala-cli

    Update sbt-mima-plugin to 1.0.0… Switch build to Scala CLI (compare)

  • Oct 05 14:11

    alexarchambault on scala-cli

    (compare)

  • Oct 05 11:05

    alexarchambault on master

    Update sbt-mima-plugin to 1.0.0… (compare)

  • Oct 05 11:05
    alexarchambault closed #229
  • Oct 05 10:08
    scala-steward opened #229
  • Oct 05 09:22

    alexarchambault on issue7

    (compare)

  • Oct 05 09:22

    alexarchambault on orphans

    (compare)

  • Oct 05 09:22

    alexarchambault on scalacheck-shapeless-1.0

    (compare)

  • Oct 05 09:22

    alexarchambault on scalacheck-shapeless-0.1

    (compare)

  • Oct 05 09:22

    alexarchambault on scalacheck-1.12

    (compare)

  • Oct 05 09:22

    alexarchambault on scalacheck-shapeless-1.1

    (compare)

  • Oct 05 09:22

    alexarchambault on scalacheck-shapeless-0.3

    (compare)

  • Oct 05 09:21

    alexarchambault on master

    Update scala-library to 2.12.15… (compare)

  • Oct 05 09:21
    alexarchambault closed #227
  • Oct 05 09:21

    alexarchambault on master

    Update sbt-mima-plugin to 0.9.2… (compare)

  • Oct 05 09:21
    alexarchambault closed #217
  • Oct 05 09:21

    alexarchambault on master

    Update sbt-scala-native-crosspr… (compare)

Olli Helenius
@liff
seems to work with a generic tag:
implicit def arbTaggedString[T]: Arbitrary[String @@ T] = Arbitrary(arbitrary[String].map(a => tag[T](a)))
but not for generic on the left (i.e. T @@ Baz)
Dario Abdulrehman
@dabd
yes it works. I'd like to understand why
Simon Hafner
@reactormonk
How do I pass in Arbitrary instances for .e.g. String? implicit val stringArb: Arbitrary[String] = Arbitrary.arbitrary[String] suchThat (_ != "") gives me a Gen[String].
implicit val stringArb: Arbitrary[String] = Arbitrary(Arbitrary.arbitrary[String] suchThat (_ != "")) looks like it works
Miguel Iglesias
@caente

I’m “generating” Arbitrarys 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)

Miguel Iglesias
@caente

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 Arbitrarys, 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...

id there a way to achieve this?
I’ve been looking at the source, but it hasn’t being obvious...
Miguel Iglesias
@caente
the main goal of all this is still to find out why the compiler hangs forever
Miguel Iglesias
@caente
and to have more control over what Arbitrarys are being used
Gabriel Assis Bezerra
@gabriel-bezerra
Hi. After I have imported org.scalacheck.Shapeless._, my v match { case O1 => f(O1) } are failing with "possible missing interpolator: detected an interpolated expression"
I have no $ over there
have you ever seen such thing
btw, def f[A](v: V[_, A])(implicit a: Arbitrary[A]): Arbitrary[A] = a
I'm not using strings or any "s around
Gabriel Assis Bezerra
@gabriel-bezerra
updating from 1.1.0-RC1 to 1.1.0-RC3 fixed it
Daniela Sfregola
@DanielaSfregola
Hi guys, I am experiencing some funny behaviours when asking scalacheck-shapeless to generate an arbitrary of a big case class (22+ fields). In particular my class has 30 fields. You can have a look at the code here: https://github.com/DanielaSfregola/random-data-generator/blob/scalacheck_shapeless_big_case_classes/src/test/scala/TestSpec.scala
the code works in the REPL -- although the arbitrary generation take a few seconds
but when I compile the code with sbt, the compiler complains that the arbitrary cannot be found.
Do you guys think it's possible that, because there are a lot of fields, the compiler gives up after a while?
also, I have noticed that the generated arbitrary are not cached (so in my case, the same arbitrary is generated over and over again)
Do you think this could be fixed? I think it will improve the compilation time significantly. Let me know what you guys think, happy to give it a try and open a PR on it!
Cheers
Olli Helenius
@liff
@DanielaSfregola that code gives me:
could not find implicit value for evidence parameter of type org.specs2.main.CommandLineAsResult[org.scalacheck.Arbitrary[BigExample]]
but works fine if i add 1 must_== 1 after implicitly[…]
Daniela Sfregola
@DanielaSfregola
ah! then it's my fault, not yours :) it's spec2 that wants an upsertion that makes sense :)
@liff thank you for looking into this!
Olli Helenius
@liff
also you could try using shapeless' cachedImplicit for caching the instance
Daniela Sfregola
@DanielaSfregola
thanks! I'll have a look
Daniela Sfregola
@DanielaSfregola
Hi @liff thank you again for looking into my issue this morning. Unfortunately, the problem is still there after fixing the test. You can see the sbt output at https://travis-ci.org/DanielaSfregola/random-data-generator/builds/160521352, the code at https://github.com/DanielaSfregola/random-data-generator/blob/scalacheck_shapeless_big_case_classes/src/test/scala/TestSpec.scala
Olli Helenius
@liff
@DanielaSfregola try with scalaVersion := "2.11.8" in your build.sbt
Daniela Sfregola
@DanielaSfregola
@liff amazing! changing the scala version fixed the issue :smile: thank you very much
Trupti
@truptitwt_twitter
Hi , I have a case class that takes an argument of type Option[javax.xml.datatype.XMLGregorianCalendar] . Does shapeless-scala library supports this type of parameter
Denis Mikhaylov
@notxcain
Hi! What could be the reason that my forAll does not terminate?
I found that if I remove a property with a type represented as sealed abstract class from a case class being generated it runs well.
Nicolas Rinaudo
@nrinaudo
I'm running in a weird problem using scalacheck-shapeless_1.13 (version 1.1.3). Here's the simplest code I could write to reproduce it:
import org.scalatest.FunSuite
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalacheck.Shapeless._

class Testor extends FunSuite with GeneratorDrivenPropertyChecks {
  sealed trait Or[+A, +B] extends Product with Serializable
  case class Left[A](a: A) extends Or[A, Nothing]
  case class Right[B](b: B) extends Or[Nothing, B]

  test("reproduce") {
    forAll { (i: Int, f: IntFloat Or Boolean) ⇒
      f(i)
    }
  }
}
this almost always fails with the following error:
RetrievalError was thrown during property evaluation.
  Message: couldn't generate value
  Occurred when passed generated values (
    arg0 = 0, // 30 shrinks
    arg1 = <function1>
  )
as you might expect, the problem goes away as soon as you provide an explicit Arbitrary[Float Or Boolean], which I take as a pretty clear indication that the problem lies in the generic derivation of the Arbitrary instance
Nicolas Rinaudo
@nrinaudo
I'd be happy to provide more information or further tests if needed, and would appreciate any help I can get with this matter :)
Nicolas Rinaudo
@nrinaudo
alright, so this does not appear to be a scalacheck-shapeless problem explicitly. I've re-implemented a simple automatic derivation mechanim and run in exactly the same issues, and this didn't use to happen when using scalacheck 1.12.5. Possibly a scalacheck regression?
Nicolas Rinaudo
@nrinaudo
@alexarchambault in #50, when you talk about recursive types, does that include Or in the following example?
sealed trait Or[+A, +B] extends Product with Serializable
case class Left[A](a: A) extends Or[A, Nothing]
case class Right[B](b: B) extends Or[Nothing, B]
I would have thought not, but #51 does not seem to fix this use case as expected. Is it because the intermediate shapeless representation is recursive?
Alexandre Archambault
@alexarchambault
@nrinaudo alexarchambault/scalacheck-shapeless#51 should have fixed that... It even tests it.
Or shouldn't be considered recursive here, yeah. Recursive is meant for trees for example (where a constructor / case class references the base trait).
Nicolas Rinaudo
@nrinaudo
@alexarchambault probably my fault then, I thought I was on #51's latest commit but I might not be
I wanted to say I really appreciate how helpful you're being with this, by the way.
Zacharias J. Beckman
@zbeckman
I have a very general question (more oriented toward scalacheck than shapeless) – are there tools for generating complex properties that demonstrate a single negative trait? For instance, let's say you have a really, really large (deeply nested) data type. You want to generate a lot of positive properties but also negative ones -- but I don't want to have every attribute fail validation. I'd rather general hundreds of properties, each one with a single attribute 'wrong'.
So far I've been able to compose properties that have an essentially randomized number of 'wrong' attributes -- but there's always the chance that 1) there will be more than one attribute that's wrong, and 2) that eventually I'll generate a property that (randomly) happens to have zero negative attributes... so it won't fail.