Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
guersam committed Sep 19, 2018
1 parent bdf9f9e commit 053b5d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
29 changes: 0 additions & 29 deletions tests/src/test/scala/cats/tests/ApplicativeErrorSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,4 @@ class ApplicativeErrorSuite extends CatsSuite {
(().raiseError[OptionWrapper, Int] orElse OptionWrapper(17.some)).option should === (OptionWrapper(17.some).option)
}
}

{
trait Super
case object Sub extends Super

final case class EitherWrapper[A](either: Either[Super, A])

implicit val EitherWrapperApplicativeError: ApplicativeError[EitherWrapper, Super] = {
val ev = ApplicativeError[Either[Super, ?], Super]
new ApplicativeError[EitherWrapper, Super] {

def raiseError[A](e: Super): EitherWrapper[A] =
EitherWrapper(ev.raiseError(e))

def handleErrorWith[A](fa: EitherWrapper[A])(f: Super => EitherWrapper[A]): EitherWrapper[A] =
EitherWrapper(ev.handleErrorWith(fa.either)(f(_).either))

def pure[A](x: A): EitherWrapper[A] =
EitherWrapper(x.asRight)

def ap[A, B](ff: EitherWrapper[A => B])(fa: EitherWrapper[A]): EitherWrapper[B] =
EitherWrapper(ev.ap(ff.either)(fa.either))
}
}

test("raiseError syntax allows an error subtype") {
assert(Sub.raiseError[EitherWrapper, Unit].either.isLeft)
}
}
}
4 changes: 4 additions & 0 deletions tests/src/test/scala/cats/tests/SyntaxSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ object SyntaxSuite extends AllSyntaxBinCompat with AllInstances with AllSyntax {
val gea4 = ga.recoverWith(pfegea)
}

def testApplicativeErrorSubtype[F[_], A](implicit F: ApplicativeError[F, CharSequence]): Unit = {
val fea = "meow".raiseError[F, A]
}

def testNested[F[_], G[_], A]: Unit = {
val fga: F[G[A]] = mock[F[G[A]]]

Expand Down

0 comments on commit 053b5d3

Please sign in to comment.