Git Product home page Git Product logo

Comments (5)

err0r500 avatar err0r500 commented on July 18, 2024 1

ok, I opened a PR for this.
Beware, I'm a 3-day-old scala dev :D

from refined.

fthomas avatar fthomas commented on July 18, 2024 1

@err0r500 Your fix is has been released in 0.10.2 and your example is working now: https://scastie.scala-lang.org/bdbcLixJRjmP0JyMltq7CA

from refined.

fthomas avatar fthomas commented on July 18, 2024

It works if you remove the arbitraryFromValidate import because startsWithArbitrary is already imported: https://scastie.scala-lang.org/3zOprdJ5R7CRdcckNGfFVQ

If your refinement becomes more complex, you probably won't have luck with arbitraryFromValidate because - as you already said - it is just a filter that discards not matching values.

from refined.

err0r500 avatar err0r500 commented on July 18, 2024

thanks @fthomas !
I use scala3 and if I just switch the target from your example, it doesn't compile : https://scastie.scala-lang.org/1J4smLVBQ86ckV9qgvf9pg

with the error :

No given instance of type org.scalacheck.Arbitrary[
  eu.timepit.refined.api.Refined[String, 
    eu.timepit.refined.string.StartsWith[("a" : String)]
  ]
] was found for parameter a1 of method forAll in object Prop.
I found:

    org.scalacheck.Arbitrary.arbContainer2[eu.timepit.refined.api.Refined, String, 
      eu.timepit.refined.string.StartsWith[("a" : String)]
    ](
      org.scalacheck.Arbitrary.arbContainer2[Tuple2, String, 
        eu.timepit.refined.string.StartsWith[("a" : String)]
      ](
        org.scalacheck.Arbitrary.arbContainer[([T2] =>> (String, T2)), 
          eu.timepit.refined.string.StartsWith[("a" : String)]
        ](
          org.scalacheck.Arbitrary.arbContainer[eu.timepit.refined.string.StartsWith
            , 
          ("a" : String)](org.scalacheck.Arbitrary.arbEnum[A], ???, ???)
        , ???, ???)
      , ???, ???)
    , ???, ???)

But method arbEnum in trait ArbitraryLowPriority does not match type org.scalacheck.Arbitrary[("a" : String)].

One of the following imports might make progress towards fixing the problem:

  import eu.timepit.refined.scalacheck.any.arbitraryFromValidate
  import shapeless.~?>.idKeyWitness
  import shapeless.~?>.idValueWitness
  import shapeless.~?>.witness

That's the reason why I had to add the arbitraryFromValidate in my example. I guess I'm doing something wrong....

from refined.

fthomas avatar fthomas commented on July 18, 2024

I guess I'm doing something wrong....

No, you are not. I just saw that startsWithArbitrary still uses shapeless.Witness but that doesn't work with Scala 3. The Scala 3 version of this instance needs to be changed to use ValueOf as is done here for example.

from refined.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.