Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 14 01:39
    scala-steward opened #142
  • Dec 14 01:37
    scala-steward opened #141
  • Nov 23 12:05

    alexarchambault on master

    Update sbt to 1.3.4 (#140) (compare)

  • Nov 23 12:05
    alexarchambault closed #140
  • Nov 23 11:43
    scala-steward opened #140
  • Nov 22 02:27
    scala-steward synchronize #132
  • Nov 21 13:59

    alexarchambault on master

    Update sbt-scalajs, scalajs-com… (compare)

  • Nov 21 13:59
    alexarchambault closed #139
  • Nov 21 13:44
    scala-steward opened #139
  • Oct 14 10:49

    alexarchambault on master

    Update sbt to 1.3.3 (#138) (compare)

  • Oct 14 10:49
    alexarchambault closed #138
  • Oct 14 10:30
    scala-steward opened #138
  • Sep 26 04:54
    scala-steward opened #137
  • Sep 24 04:05
    scala-steward synchronize #132
  • Sep 23 20:31

    alexarchambault on master

    Update sbt-ci-release to 1.4.31… (compare)

  • Sep 23 20:31
    alexarchambault closed #136
  • Sep 23 18:27
    scala-steward opened #136
  • Sep 21 14:33
    alexarchambault closed #130
  • Sep 21 14:33
    alexarchambault commented #130
  • Sep 21 14:15
    alexarchambault opened #135
Luciano
@lJoublanc
I'll try it out.
Luciano
@lJoublanc
yeah that doesn't work :( trying to do Arbitrary[Int :+: Long]. On the other hand Arbitrary[AnyVal] does work, but I get lots of stuff I don't want (Unit) for example.
Georgi Krastev
@joroKr21
There is definitely an Arbitrary for Coproducts somewhere in there, maybe it's just not exposed. Look around the source code.
found it - MkCoproductArbitrary
Luciano
@lJoublanc
Thanks @joroKr21 will check it out today.
Marko Dimjašević
@mdimjasevic
Hi everyone!
I'd like to generate sequences of valid state machine transitions. Any idea how to do this with scalacheck-shapeless? I was thinking of using IndexedStateT from https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/data/IndexedStateT.scala to encode an input and output state of a transition.
Ihor Kaharlichenko
@kaharlichenko
Hi. Is there any way I could customize the generator for a case class? Suppose I have case class Person(name: String, age: Int) and I want age to be generated as Gen.posNum, while the rest of the field generators being derived?
Olli Helenius
@liff
@kaharlichenko well if you have arbPerson: Arbitrary[Person] you could do something like:
implicit val properArbPerson: Arbitrary[Person] = Arbitrary(arbPerson.arbitrary.flatMap(person => Gen.posInt.map(age => person.copy(age = age))))
alternatively you could create a distinct type for age, possibly with refined, newtype or otherwise. then you could just create an arbAge: Arbitrary[Age] and not worry about how a Person is generated
Ihor Kaharlichenko
@kaharlichenko
Well, changing the type of age is not an option, since that would involve changing the production code for the sake of testing. The second option is viable, though. Thank you.
Jason Pickens
@steinybot
Do the generated Arbitrarys ignore other implicits in scope? I haven’t been able to confirm or deny yet but it seems to be the case. For example:
case class Foo(bar: Bar)
implicit val arbBar: Arbitrary[Bar] = somePredefinedArbitraryForBar // This is not used
implicit val arbFoo: Arbitrary[Foo] = MkArbitrary[Foo].arbitrary
Jason Pickens
@steinybot
may have been a PBKAC error
Jason Pickens
@steinybot
Does the library work with recursive types?
I’m getting a StackOverflowError but it might just be me again
Paul Snively
@PaulAtFormation
Could someone please offer an example of generating a Shapeless Coproduct, presumably using the aforementioned MkCoproductArbitrary? I'm getting:
could not find implicit value for parameter mkArb: org.scalacheck.derive.MkCoproductArbitrary[takt.data.valkyrie.deployables.etl.VAL1081.ValkyrieType]
Alex
@unthingable
Hello. How does one confine generated String vals for a given case class to non-Unicode characters?
Daniel Sebban
@dsebban
Hi I am getting at runtime ava.lang.IllegalArgumentException: requirement failed: Duration is limited to +-(2^63-1)ns (ca. 292 years) [info] at scala.concurrent.duration.FiniteDuration.<init>(Duration.scala:583) [info] at scala.concurrent.duration.Duration$.apply(Duration.scala:31) [info] at scala.concurrent.duration.package$DurationLong$.durationIn$extension(package.scala:48) [info] at scala.concurrent.duration.package$DurationLong.durationIn(package.scala:48)
is there a way to override the Duration generator implicit with a correct one
?
Gabriel Assis Bezerra
@gabriel-bezerra
as far as I know, the Arbitrary[T]s in scope are preferred instead of the derived ones
import /*the automatic derivation from the library*/

implicit val arbitraryDuration: Arbitrary[Duration] = ...

implicitly[Arbitrary[SomethingThatNeedsDuration]] // this should use arbitraryDuration
Luciano
@lJoublanc

Was just about to post practically the same question as above ... I have:

case class Dense[K: Field](layout: Layout, stride: Int)

but if I put an implicit val stride: Arbitrary[Int] = ... before forAll, in order to limit the values of stride, it's not being picked up. It sounds like the same problem as above?

Luciano
@lJoublanc
@dsebban how did you finally resolve your issue?
Luciano
@lJoublanc
Ah figured it out - it's the old 'shrink' problem ...
Edmondo Porcu
@edmondo1984
Hello everyone, how can I get my arbitrary for "integers"
to override a default one only for a specific field of a case class?
Luciano
@lJoublanc
Don't think you can do that. You may be able to override the arbitrary for that specific case-class instead though.
Dario Abdulrehman
@dabd
I may be using it incorrectly but I attempted to use scalacheck-shapeless to automatically generate data for a sealed trait hierarchy. It turned out that the generators are very generic and not very useful for my purposes. For example a case class with a String field apparently uses Arbitrary.arbString and that is too generic for my application. Is there a way to customise the generators for a field using the library?
Dario Abdulrehman
@dabd
The only way around it I found is to use tagged types and write Arbitrary implicits.
Georgi Krastev
@joroKr21
I guess depending on your taste you could also just import your own implicit Arbitrary[String]
If you don't mind having orphan typeclass instances
Dario Abdulrehman
@dabd
I suppose @edmondo1984 was asking a similar question above
Dario Abdulrehman
@dabd
@joroKr21 and what if your case class has two different fields of type String which need different instances of Arbitrary. I think in this case you have to use tagged types.
Georgi Krastev
@joroKr21
I'm not sure I would have to check
Dario Abdulrehman
@dabd
The implicit mess + tagged types makes it easier to just hand-craft the case class generators.
Georgi Krastev
@joroKr21
yeah if you want customization might be easier to handroll it
with mapN
In theory it would be easy to make it work with LabelledGeneric
And customize your generators based on the field name
But I don't think it exists in scalacheck-shapeless ATM
Akhtiam Sakaev
@asakaev

Hello. I am getting compiler "stackoverflow" when trying to derive generators for scalapb data.

at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.scala$tools$nsc$typechecker$Implicits$ImplicitSearch$$typedImplicit(Implicits.scala:622)
        at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation.rankImplicits(Implicits.scala:1213)
        at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation.findBest(Implicits.scala:1248)
        at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1305)
        at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1730)
        at scala.tools.nsc.typechecker.Implicits.inferImplicit1(Implicits.scala:112)
        at scala.tools.nsc.typechecker.Implicits.inferImplicit(Implicits.scala:91)
        at scala.tools.nsc.typechecker.Implicits.inferImplicit$(Implicits.scala:88)
        at scala.tools.nsc.Global$$anon$5.inferImplicit(Global.scala:483)
        at scala.tools.nsc.typechecker.Implicits.$anonfun$inferImplicit$1(Implicits.scala:144)
        at scala.tools.nsc.typechecker.Implicits.inferImplicit(Implicits.scala:144)
        at scala.tools.nsc.typechecker.Implicits.inferImplicit$(Implicits.scala:142)
        at scala.tools.nsc.Global$$anon$5.inferImplicit(Global.scala:483)
        at scala.reflect.macros.contexts.Typers.inferImplicitValue(Typers.scala:56)
        at scala.reflect.macros.contexts.Typers.inferImplicitValue$(Typers.scala:54)
        at scala.reflect.macros.contexts.Context.inferImplicitValue(Context.scala:18)
        at scala.reflect.macros.contexts.Context.inferImplicitValue(Context.scala:18)
        at shapeless.LazyMacros$DerivationContext$State$.resolveInstance(lazy.scala:303)
        at shapeless.LazyMacros$DerivationContext.resolve0(lazy.scala:421)
        at shapeless.LazyMacros$DerivationContext.$anonfun$deriveLowPriority$1(lazy.scala:449)
        at scala.Option.flatMap(Option.scala:283)
        at shapeless.LazyMacros$DerivationContext.helper$2(lazy.scala:446)
        at shapeless.LazyMacros$DerivationContext.deriveLowPriority(lazy.scala:483)
        at shapeless.LazyMacros$DerivationContext.derive(lazy.scala:494)
        at shapeless.LazyMacros$DerivationContext$State$.deriveInstance(lazy.scala:327)
        at shapeless.LazyMacrosCompat.deriveInstance(lazymacros.scala:50)
        at shapeless.LazyMacrosCompat.deriveInstance$(lazymacros.scala:33)
        at shapeless.LazyMacros$.deriveInstance(lazy.scala:573)
        at shapeless.LazyMacros.mkImpl(lazy.scala:216)
        at shapeless.LazyMacros.mkStrictImpl(lazy.scala:209)
        at shapeless.LazyMacrosRef.mkStrictImpl(lazyref.scala:39)
        at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$5(JavaReflectionRuntimes.scala:45)

Can I do something with this or I have big nested type that can not be derived?

Georgi Krastev
@joroKr21
You could try bumping up the stack
I usually go for -Xss2m
Akhtiam Sakaev
@asakaev
@joroKr21 4m already, doesn't helps 🤷‍♂️
Georgi Krastev
@joroKr21
But do you see a loop in the stack trace? From the part you shared I don't.
Also how big is this nested type?
One thing you might try is break it up, i.e. derive generators for the inner types first and then for the outer ones.