eu.timepit.refined.scalacheck.any.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of refined-scalacheck_sjs0.6_2.10 Show documentation
Show all versions of refined-scalacheck_sjs0.6_2.10 Show documentation
Simple refinement types for Scala
The newest version!
package eu.timepit.refined
package scalacheck
import eu.timepit.refined.api.{RefType, Validate}
import org.scalacheck.Arbitrary
/**
* Module that provides an `Arbitrary` instance for any refined type
* `F[T, P]`.
*
* This instance uses the `Arbitrary` instance of the base type `T` and
* the corresponding `Validate[T, P]` instance of the refinement to filter
* out invalid values. For most refinements this will cause ScalaCheck to
* fail because this instance will discard too many values.
*/
object any {
implicit def arbitraryFromValidate[F[_, _], T, P](
implicit rt: RefType[F],
v: Validate[T, P],
arb: Arbitrary[T]
): Arbitrary[F[T, P]] =
arbitraryRefType(arb.arbitrary.filter(v.isValid))
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy