Skip to content

Commit

Permalink
Make Tree arbitrary instance visible
Browse files Browse the repository at this point in the history
  • Loading branch information
Luka Jacobowitz committed Sep 4, 2017
1 parent bb78377 commit c8c4328
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions docs/src/main/tut/typeclasses/lawtesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,25 @@ Cats has defined rulesets for all type class laws in `cats.laws.discipline.*`.

So for our example we will want to import `cats.laws.discipline.FunctorTests` and call `checkAll` with it.
Before we do so, however,
we will have to bring our instances into scope as well as the derived `Arbitrary` instances from `scalacheck-shapeless`:
we will have to bring our instances into scope as well as the derived `Arbitrary` instances from `scalacheck-shapeless`
(We have defined an Arbitrary instance for `Tree` here, but you won't need it if you import `org.scalacheck.Shapeless._`).



```tut:silent
import Tree._
```
```scala
import org.scalacheck.Shapeless._
```
```tut:invisible
import org.scalacheck.{Arbitrary, Gen}
implicit def arbFoo[A: Arbitrary]: Arbitrary[Tree[A]] =
Arbitrary(Gen.oneOf(Gen.const(Leaf), (for {
e <- Arbitrary.arbitrary[A]
} yield Node(e, Leaf, Leaf).asInstanceOf[Tree[A]]))
} yield Node(e, Leaf, Leaf)))
)
```

```tut:book
import Tree._
import cats.laws.discipline.FunctorTests
class TreeLawTests extends CatsSuite {
Expand Down

0 comments on commit c8c4328

Please sign in to comment.