Releases: typelevel/coop
Releases · typelevel/coop
v0.2.1
- Added
ThreadT.prettyPrint
, which provides a mechanism for rendering effects as a nice textual tree
As an example:
import coop._
import cats._
import cats.data._
import cats.implicits._
import ThreadT._
type M[A] = WriterT[Eval, List[Int], A]
val main = for {
m <- monitor[M]
_ <- start {
ThreadT.await[M](m) >> liftF(WriterT.tell(0 :: Nil))
}
_ <- start {
ThreadT.await[M](m) >> liftF(WriterT.tell(1 :: Nil))
}
_ <- start {
ThreadT.await[M](m) >> liftF(WriterT.tell(2 :: Nil))
}
_ <- cede[M]
_ <- ThreadT.notify[M](m)
_ <- liftF[M, Unit](WriterT.tell(3 :: Nil))
} yield ()
ThreadT.prettyPrint(main).run.value._2
This produces the following String
:
╭ Fork
│ ╰╮
│ ├ Await 0x4FE54178
│ ╰ Done
│
├ Fork
│ ╰╮
│ ├ Await 0x4FE54178
│ ╰ Done
│
├ Fork
│ ╰╮
│ ├ Await 0x4FE54178
│ ╰ Done
│
├ Cede
├ Notify 0x4FE54178
╰ Pure ()
An optional parameter of type M ~> Lambda[a => Option[String]]
is accepted for cases where there is a mechanism for rendering some (or all) M
effects to strings.