treelog icon indicating copy to clipboard operation
treelog copied to clipboard

Missing DescribedComputationT instances ?

Open ronanM opened this issue 6 years ago • 0 comments

I start using DescribedComputationT

import cats.effect.IO
import cats.effect.implicits._
import treelog.LogTreeSyntaxWithoutAnnotations._

type DctIO[A] = DescribedComputationT[IO, A]

def good(i: Int): DctIO[Int] = DescribedComputationT(IO(i ~> ("i: " + _)))

def bad(i: Int): DctIO[Int] = DescribedComputationT(IO(i ~>! ("i: " + _)))

I had also

def goodIO(i: Int): IO[Int] = IO(i)

def badIO(i: Int): IO[Int] = IO.raiseError(new Throwable(s"Bad $i"))

Then I start writing a simple ScalaTest:

"TreeLog" - {
  "Basic IO" in goodIO(10).unsafeToFuture().map(v => assert(v === 10))
  "Basic"    in good(10).run.unsafeToFuture().map(v => assert(v.value.value === 10.asRight))

  "<* IO" in (goodIO(10) <* goodIO(42)).unsafeToFuture().map(v => assert(v === 10))
  "<*"    in (good(10) <* good(42)).run.unsafeToFuture().map(v => assert(v.value.value === 10.asRight)) 
                       ^ Error: <* is not a member of DctIO

  "tupled IO" in (goodIO(10), goodIO(42)).tupled.unsafeToFuture().map(v => assert(v === (10, 42)))
  "tupled"    in (good(10), good(42)).tupled.run.unsafeToFuture().map(v => assert(v.value.value === (10, 42).asRight))
                                      ^ Error: could not find implicit value for parameter invariant: cats.Invariant[DctIO]

  "recover IO" in badIO(10).recoverWith { case _ => goodIO(42) }.unsafeToFuture().map(v => assert(v === 42))
  "recover"    in bad(10).recoverWith { case _ => good(42) }.run.unsafeToFuture().map(v => assert(v.value.value === 42.asRight))
                          ^ Error: recoverWith is not a member of DctIO[Int]
}

ronanM avatar May 18 '19 08:05 ronanM