https://github.com/scalaprops/scalaprops-deriving
scalaz-deriving instances for scalaprops. generation of arbitrary case classes / ADTs instances
https://github.com/scalaprops/scalaprops-deriving
compiler-plugin macros scalaprops scalaz typeclass-derivation
Last synced: 2 months ago
JSON representation
scalaz-deriving instances for scalaprops. generation of arbitrary case classes / ADTs instances
- Host: GitHub
- URL: https://github.com/scalaprops/scalaprops-deriving
- Owner: scalaprops
- License: mit
- Created: 2019-08-23T15:06:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2026-04-07T06:21:06.000Z (2 months ago)
- Last Synced: 2026-04-07T07:25:32.413Z (2 months ago)
- Topics: compiler-plugin, macros, scalaprops, scalaz, typeclass-derivation
- Language: Scala
- Homepage:
- Size: 105 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# scalaprops-deriving
[](https://javadoc.io/doc/com.github.scalaprops/scalaprops-deriving_2.13)
[scalaz-deriving](https://github.com/scalaz/scalaz-deriving) instances for [scalaprops](https://github.com/scalaprops/scalaprops)
### build.sbt
```scala
libraryDependencies += "com.github.scalaprops" %% "scalaprops-deriving" % "0.3.0"
```
### macro example
```scala
package example
import scalaprops.{Cogen, Gen}
import scalaz.Deriving
import scalaprops.ScalapropsDeriving._
sealed trait A extends Any
object A {
implicit val genInstance: Gen[A] =
Deriving.gen[Gen, A]
implicit val cogenInstance: Cogen[A] =
Deriving.gen[Cogen, A]
}
final case class B(x: Int) extends AnyVal with A
object B {
implicit val genInstance: Gen[B] =
Deriving.gen[Gen, B]
implicit val cogenInstance: Cogen[B] =
Deriving.gen[Cogen, B]
}
// support recursive data structure!
final case class C(y: Boolean, z: Option[A]) extends A
object C {
implicit val genInstance: Gen[C] =
Deriving.gen[Gen, C]
implicit val cogenInstance: Cogen[C] =
Deriving.gen[Cogen, C]
}
```
### compiler plugin example
#### build.sbt
```scala
addCompilerPlugin("org.scalaz" %% "deriving-plugin" % "3.0.0-M6")
```
#### source code
```scala
import scalaprops.{Cogen, Gen}
import scalaz.annotation.deriving
import scalaprops.ScalapropsDeriving._
@deriving(Gen, Cogen)
sealed trait A extends Any
@deriving(Gen, Cogen)
final case class B(x: Int) extends AnyVal with A
@deriving(Gen, Cogen)
final case class C(y: Boolean, z: Option[A]) extends A
```