Skip to content

Releases: typelevel/coop

v0.2.1

02 Jan 18:44
v0.2.1
Compare
Choose a tag to compare
  • 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.

v0.2.0

29 Dec 17:44
v0.2.0
Compare
Choose a tag to compare
  • Added first-class support for locking
  • Used the above to implement deadlock detection
  • Removed cede_ and made cede always produce Unit, because more sugar