An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# scalaprops-deriving

[![scaladoc](https://javadoc.io/badge2/com.github.scalaprops/scalaprops-deriving_2.13/javadoc.svg)](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
```