Skip to content

Commit

Permalink
Improve StateT Arbitrary instance
Browse files Browse the repository at this point in the history
As pointed out [here](typelevel#1640 (comment))

This reveals law violations in `StateT`. It looks like `flatMap`/`ap`
consistency does not hold, as well as `MonadCombine`
right-distributivity. It's not immediately clear to me how to fix this,
so I'm opening this up in case somebody else gets to it first.
  • Loading branch information
ceedubs committed Jun 1, 2017
1 parent 4e55158 commit 06011a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions laws/src/main/scala/cats/laws/discipline/Arbitrary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ object arbitrary extends ArbitraryInstances0 {

private[discipline] sealed trait ArbitraryInstances0 {

implicit def catsLawArbitraryForStateT[F[_]: Applicative, S, A](implicit AS: Arbitrary[S], CS: Cogen[S], F: Arbitrary[F[(S, A)]]): Arbitrary[StateT[F, S, A]] =
Arbitrary(Arbitrary.arbitrary[S => F[(S, A)]].map(StateT(_)))
implicit def catsLawArbitraryForStateT[F[_], S, A](implicit F: Arbitrary[F[S => F[(S, A)]]]): Arbitrary[StateT[F, S, A]] =
Arbitrary(F.arbitrary.map(StateT.applyF))

implicit def catsLawsArbitraryForWriterT[F[_], L, V](implicit F: Arbitrary[F[(L, V)]]): Arbitrary[WriterT[F, L, V]] =
Arbitrary(F.arbitrary.map(WriterT(_)))
Expand Down

0 comments on commit 06011a1

Please sign in to comment.